当前位置: 首页 > 后端技术 > PHP

关于PHP精算模块BC函数

时间:2023-03-29 23:01:21 PHP

PHP精算:bc是BinaryCalculator的缩写。bc*函数的参数是操作数加上一个可选的[intscale],如stringbcadd(string$left_operand,string$right_operand[,int$scale]),如果没有提供scale,则使用默认的bcscale值。这里大数直接用0-9组成的字符串表示,计算结果也是字符串特有的函数:bcadd——两个高精度数相加  stringbcadd(stringleftoperand,stringrightoperand[,intscale]);bccomp—比较两个高精度数,返回-1,0,1  intbccomp(stringleftoperand,stringrightoperand[,intscale]);bcdiv—比较两个高精度数Divide  stringbcdiv(stringleftoperand,stringrightoperand[,intscale]);bcmod—求一个高精度数的余数  stringbcmod(stringleftoperand,弦模数);bcmul—将两个高精度数字相乘  stringbcmul(stringleftoperand,stringrightoperand[,intscale]);bcpow—求一个高精度数字幂  stringbcpow(stringx,stringy[,intscale]);bcpowmod—求高精度数字幂和模,在数论中非常常用  stringbcpowmod(stringx,stringy,stringmodulus[,intscale]);bcscale—配置默认小数位数,相当于Linux中的"scale="bc”  stringbcscale(intscale);bcsqrt—求一个高精度数的平方根  stringbcsqrt(stringoperand[,intscale]);bcsub—两个高精度数相减  stringbcsub(stringleftoperand,stringrightoperand[,intscale]);