【发布时间】:2020-03-11 02:06:11
【问题描述】:
我正在尝试接收小数(最多 8 位小数)的数学运算结果,我收到一个浮点结果,但其格式会使其他数字保持错误:
$a = round($x, 8); //returns 0.0478674, that's correct
$b = round($y,8); //returns 0.04786261, that's correct
$z = $a - $b; //z returns 4.7899999999976E-6, and not 0.00000479 as I was expecting
我也试过了
$w = round($z,8); //but w returns 4.79E-6, and not 0.00000479 as I was expecting
我的问题是因为数字4.7899999999976E-6 在其他计算中出现错误,并且它是一个难看的数字,无法显示给用户。
我怎样才能让这个号码成为0.00000479?
【问题讨论】: