我们都知道处理浮点数可能会遇到这样的麻烦:
echo intval(0.58*100);//57
使用 bcmath 函数将有助于:
echo bcmul('0.58', '100', 2);//58.00
php手册:
//Multiply the left_operand by the right_operand.
string bcmul(string $left_operand , string $right_operand [, int $scale = 0 ])
但是为什么会这样呢?
我注意到前两个参数应该是字符串,我想知道这是不是因为这些函数以字符串方式处理数字?