一、运算
$a–浮点数1 $b–浮点数2 $c–小数点
加: $result= bcadd( $a, $b, $c);
减: $result= bcsub( $a, $b, $c);
乘: $result= bcmul( $a, $b, $c);
除: $result= bcdiv( $a, $b, $c);
bcadd — 将两个高精度数字相加
bccomp — 比较两个高精度数字,返回-1, 0, 1
bcdiv — 将两个高精度数字相除
bcmod — 求高精度数字余数
bcmul — 将两个高精度数字相乘
bcpow — 求高精度数字乘方
bcpowmod — 求高精度数字乘方求模,数论里非常常用
bcscale — 配置默认小数点位数,相当于就是Linux bc中的”scale=”
bcsqrt — 求高精度数字平方根
bcsub — 将两个高精度数字相减
二、比较
语法: int bccomp(string left operand, string right operand, int [scale]);
返回值: 整数
函数种类: 数学运算
解析:
此函数比较二个高精确度的数字。输入二个字符串,若二个字符串一样大则返回 0;若左边的数字字符串 (left operand) 比右边 (right operand) 的大则返回 +1;若左边的数字字符串比右边的小则返回 -1。scale 是一个可有可无的选项,表示返回值的小数点后所需的位数。
转自:https://www.cnblogs.com/gumo9/p/13892478.html