留意:备选参数$scale以设置运算精度(保留小数位)。

bcscale(设置运算精度)
bool bcscale ( int $scale )
说明:设置运算精度(保留小数位),成功返回TRUE否则为FALSE。

bcadd(加法运算)
string bcadd ( string $left_operand , string $right_operand [, int $scale] )
说明:返回$left_operand+$right_operand的和。

bcsub(减法运算)
string bcsub ( string $left_operand , string $right_operand [, int $scale ] )
返回:$left_operand 减去$right_operand的值。

bcmul(乘法运算)
string bcmul ( string $left_operand , string $right_operand [, int $scale] )
说明:返回$left_operand乘以$right_operand的值。

bcdiv(除法运算)
string bcdiv ( string $left_operand , string $right_operand [, int $scale] )
说明:返回$left_operand除以$right_operand的值。

bccomp(比较运算)
int bccomp ( string $left_operand , string $right_operand [, int $scale] )
说明:返回值为0相等;1,$left_operand大;-1,$right_operand大。

bcmod(取余运算)
string bcmod ( string $left_operand , string $modulus )
说明:返回$left_operand除$modulus的余数。返回 NULL则$modulus为0。

bcpow(次方|幂运算)
string bcpow ( string $left_operand , string $right_operand [, int $scale] )
说明:返回$left_operand的$right_operand次方的幂值。

在不需要精度控制的情况下,将不会返回小数保留位。如

<?php
echo bcpow('5', '2', 2); // 显示 "25", 而不是 "25.00"
?>

bcpowmod(次方取余运算)
string bcpowmod ( string $left_operand , string $right_operand , string $modulus [, int $scale] )
说明:返回$left_operand的$right_operand次方,再与 $modulus取余。
即:($left_operand^$right_operand) mod $modulus

<?php
$a = bcpowmod($x, $y, $mod);

$b = bcmod(bcpow($x, $y), $mod);

//$a 和 $b 相同。

?>

bcsqrt(平方根运算)
string bcsqrt ( string $operand [, int $scale] )
说明:返回$operand的平方根。

相关: