频道直达 - 专题 - 新闻 - 基础 - 高级 - 安装 - 技巧 - 数据库 - 手册 - PHP - Linux - Java - MySQL - Apache - 麻辣堂 - 狼盟 - Rails社群 - 搜索 - 下载 - 开源 - 论坛
PHP开发资源网 主页>>高级应用>> 收藏此文 | 收藏本站 | 设为首页

PHP4.04 增加了对无限精度运算的支持

来源:www.phpres.com 作者:Angelover 出处:www.phpres.com 2007-7-19 13:32:05 进入讨论组
关 键 词: PHP4.04 增加了对无限精度运算的支持

These functions allow you to work with arbitrary-length integers using the GNU MP library. In order to have these functions available, you must compile PHP with GMP support by using the --with-gmp option.
通过 GUN MP 库,这些函数允许你使用任意长度的整数。你需要编译 php 时使用 --with-gmp 参数

 

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 或更好的来使用这些函数。某些函数可能需要最新的 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.
注意:大多数 GMP 函数接受下面资源定义的 GMP 数值参数,当然,大多数函数也接受数字和字符串参数,但是会被转化为数字。同时,如果存在更快的函数来操作整形参数,则会使用那个更快的函数来操作整数。这是当然的,所以你可以在需要 GMP 数字的地方用整数参数。

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.

欢迎进入PHP开发资源论坛讨论。
收藏此文】【 】【打印】【关闭
相关文章
图文推荐
论 坛 资 源
PHP开发资源网奋斗目标
阅读排行:
热门技术文档
最新图文档
本站编辑推荐:(本站开通Delphi4PHP专区,欢迎进入论坛交流!)
编缉最近更新文章
网站赞助商
搜索您感兴趣的内容
 
   网站首页 -  网站地图 -  网站合作 -  手册中心 -  通用网址 -  网站论坛 -  网站投稿 -  友情链接 -  帮助中心
版权所有:PHP开发资源网 © 2003-2008 通用网址:PHP资源网 合作媒体: 赛迪网IT技术
互联网违法和不良信息举报中心 | 不良信息举报信箱