大数字精确计算

2019-07-09  本文已影响0人  Karsure

数字太大普通运算法则计算结果会有偏差,可以用到BC 高精确度函数库

相乘

bcmul(string left operand, string right operand, int [scale]);

相除
bcdiv(string left operand, string right operand, int [scale]);

相加
string bcadd(string left operand, string right operand, int [scale]);

相减
 bcsub(string left operand, string right operand, int [scale]);

次方计算
string bcpow(string x, string y, int [scale]);

平方根
bcsqrt(string operand, int [scale]);

配置程序中所有 BC 函数库的内定小数点位数
cscale(int scale);

取余
bcmod(string left operand, string modulus);

比较
bccomp(string left operand, string right operand, int [scale]);

上一篇 下一篇

猜你喜欢

热点阅读