|
PHP5中文手册
GMP Functions简介These functions allow you to work with arbitrary-length integers using the GNU MP library. These functions have been added in PHP 4.0.4.
Warning
If you want to explicitly specify a large integer, specify it as a string. If you don't do that, PHP will interpret the integer-literal first, possibly resulting in loss of precision, even before GMP comes into play.
需求You can download the GMP library from » http://www.swox.com/gmp/. This site also has the GMP manual available. You will need GMP version 2 or better to use these functions. Some functions may require more recent version of the GMP library. 安装In order to have these functions available, you must compile PHP with GMP support by using the --with-gmp option. 运行时配置本扩展模块在 php.ini 中未定义任何配置选项。 资源类型Most GPM functions operate on or return GMP number resources. 预定义常量以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。 范例
Example#1 Factorial function using GMP
<?php This will calculate factorial of 1000 (pretty big number) very fast. 参见More mathematical functions can be found in the sections BCMath Arbitrary Precision Mathematics Functions and Mathematical Functions. Table of Contents
|