当前位置:Gxlcms > PHP教程 > php精准计算模块bcmath

php精准计算模块bcmath

时间:2021-07-01 10:21:17 帮助过:36人阅读

bc是Binary Calculator的缩写。bc*函数的参数都是操作数加上一个可选的 [int scale],比如string bcadd(string $left_operand, string $right_operand[, int $scale]),如果scale没有提供,就用bcscale的缺省值。这里大数直接用一个由0-9组成的string表示,计算结果返回的也是一个 string。


bcadd ? 将两个高精度数字相加
bccomp ? 比较两个高精度数字,返回-1, 0, 1
bcdiv ? 将两个高精度数字相除
bcmod ? 求高精度数字余数
bcmul ? 将两个高精度数字相乘
bcpow ? 求高精度数字乘方
bcpowmod ? 求高精度数字乘方求模,数论里非常常用
bcscale ? 配置默认小数点位数,相当于就是Linux bc中的”scale=”
bcsqrt ? 求高精度数字平方根

bcsub ? 将两个高精度数字相减

windows下直接修改php.ini配置文件

[bcmath]; Number of decimal digits for all bcmath functions.; http://php.com/bcmath.scalebcmath.scale = 1
然后重启apache。

linux下需要重新编译apache

人气教程排行