Installation
In order to have these functions available, you must compile
PHP with GMP support by using the --with-gmp option.
Runtime Configuration
This extension has no configuration directives defined in
php.ini.
Resource Types
This extension has no resource types defined.
Predefined Constants
The constants below are defined by this extension, and will
only be available when the extension has either been compiled
into PHP or dynamically loaded at runtime.
GMP_ROUND_ZERO (integer)
GMP_ROUND_PLUSINF (integer)
GMP_ROUND_MINUSINF (integer)
Examples
Example 1. Factorial function using GMP
<?php
function fact($x)
{
if ($x <= 1) {
return 1;
} else {
return gmp_mul($x, fact($x-1));
}
}
echo gmp_strval(fact(1000)) . "\n";
?>
This will calculate factorial of 1000 (pretty big number)
very fast.
|