直播中
You can download the GMP library from http://www.swox.com/gmp/. This site also has the GMP manual available.
你可以從 http://www.swox.com/gmp/ 下載 GMP 庫,同時有手冊。
You will need GMP version 2 or better to use these functions. Some functions may require more recent version of the GMP library.
你需要 GMP 2.0 或更好的來使用這些函數(shù)。某些函數(shù)可能需要最新的 GMP庫
These functions have been added in PHP 4.0.4.
Note: Most GMP functions accept GMP number arguments, defined as resource below. However, most of these functions will also accept numeric and string arguments, given that it is possible to convert the latter to a number. Also, if there is a faster function that can operate on integer arguments, it would be used instead of the slower function when the supplied arguments are integers. This is done transparently, so the bottom line is that you can use integers in every function that expects GMP number. See also the gmp_init() function.
注意:大多數(shù) GMP 函數(shù)接受下面資源定義的 GMP 數(shù)值參數(shù),當然,大多數(shù)函數(shù)也接受數(shù)字和字符串參數(shù),但是會被轉(zhuǎn)化為數(shù)字。同時,如果存在更快的函數(shù)來操作整形參數(shù),則會使用那個更快的函數(shù)來操作整數(shù)。這是當然的,所以你可以在需要 GMP 數(shù)字的地方用整數(shù)參數(shù)。
Example 1. Factorial function using GMP
<?php
function fact ($x) {
if ($x <= 1)
return 1;
else
return gmp_mul ($x, fact ($x-1));
}
print gmp_strval (fact (1000)) . "n";
?>
This will calculate factiorial of 1000 (pretty big number) very fast.