These functions allow you to work with arbitrary-length integers using the GNU MP library. In order to has these functions available, you must compile PHP with GMP support by using the--WITH-GMP option.
Through the GUN MP library, these functions allow you to use integers of any length. You need to compile PHP using the--WITH-GMP parameter
You can download the GMP library from http://www.swox.com/gmp/. This site also has the GMP manual available.
You can download the GMP library from http://www.swox.com/gmp/and have a manual.
You'll need GMP version 2 or better to use these functions. Some functions may require more recent version of the GMP library.
You need GMP 2.0 or better to use these functions. Some functions may require the latest GMP library
These functions has been added in PHP 4.0.4.
Note:most GMP functions Accept GMP number arguments, defined as resource below. However, most of these functions would also accept numeric and string arguments, given that it's possible to convert the L Atter to a number. Also, if there is a faster function so can operate on integer arguments, it would be used instead of the slower function When the supplied arguments is integers. This is do transparently, so the bottom line is, which can use integers in every function that expects GMP number. See also the Gmp_init () function.
NOTE: Most GMP functions accept the GMP numeric parameters defined by the resources below, and of course, most functions accept both numeric and string parameters, but are converted to numbers. At the same time, if there is a faster function to manipulate the shaping parameters, then the faster function is used to manipulate the integers. This is of course, so you can use integer parameters where GMP numbers are needed.
Example 1. factorial function using GMP
function Fact ($x) {
if ($x <= 1)
return 1;
Else
Return Gmp_mul ($x, Fact ($x-1));
}
Print Gmp_strval (fact (1000)). "N";
?>
This would calculate factiorial of (pretty big number) very fast.
http://www.bkjia.com/PHPjc/532488.html www.bkjia.com true http://www.bkjia.com/PHPjc/532488.html techarticle These functions allow you to work with arbitrary-length integers using the GNU MP library. In order to has these functions available, you must compile PHP with GMP support by usin ...