大愚就是这样一个程序员

PHP中处理浮点数的一些方法记录

请不要在程序中直接使用等号、大于、加、减、乘、除等操作浮点数,如果需要对浮点数进行以上操作,请使用下面的BC系列函数。以确保准确性及精度。

两个高精度数比较大小int bccomp ( string $left_operand , string $right_operand [, int $scale ] )两个高精度数相加string bcadd ( string $left_operand , string $right_operand [, int $scale ] )$scale 相加后,返回几位小数两个高精度数相减string bcsub ( string $left_operand , string $right_operand [, int $scale ] )$scale 相减后,返回几位小数两个高精度数求余/取模string bcmod ( string $left_operand , string $modulus )两个高精度数相除string bcdiv ( string $left_operand , string $right_operand [, int $scale ] )$scale 相除后,,返回几位小数两个高精度数相乘string bcmul ( string $left_operand , string $right_operand [, int $scale ] )$scale 相乘后,返回几位小数两个高精度数的次方值string bcpow ( string $left_operand , string $right_operand [, int $scale ] )$scale 次方,返回几位小数高精度数的平方根string bcsqrt ( string $operand [, int $scale ] )$scale 返回几位小数设置bc函数的小数点位数bool bcscale ( int $scale )$scale 几位小数

先知三日,富贵十年。

大愚就是这样一个程序员

相关文章:

你感兴趣的文章:

标签云: