One - One Code All

Blog Content

PHP基础之bcmod,bcadd

PHP   2011-04-16 22:07:05

bcmod — 对一个任意精度数字取模

说明

string bcmod ( string $left_operand , string $modulus )


对左操作数使用系数取模

参数 

left_operand:字符串类型的左操作数

modulus:字符串类型系数


返回值:返回字符串类型取模后结果,如果系数为0则返回null

举例:

echo bcmod('4', '2'); // 0
echo bcmod('2', '4'); // 2


bcadd — 2个任意精度数字的加法计算

string bcadd ( string $left_operand , string $right_operand [, int $scale ] )

左操作数和右操作数求和

参数:

left_operand,左操作数,字符串类型

right_operand,右操作数,字符串类型

scale,此可选参数用于设置结果中小数点后的小数位数。也可通过使用 bcscale() 来设置全局默认的小数位数,用于所有函数。 


其他加减乘除乘方等计算参考官网链接:http://php.net/manual/zh/function.bcpow.php


上一篇:PHP跨域访问设置
下一篇:PHP短链接生成算法

The minute you think of giving up, think of the reason why you held on so long.