我有一种情况,我把一个双变量转换成整数。它给了我错误的结果。为什么会这样?
>>> $amount = (double) 1052.10 => 1052.1 >>> $amount = $amount * 100; => 105210.0 >>> (int) $amount; => 105209 // weird
我可以先将变量四舍五入(即: (int) round($amount)
(int) round($amount)
但我还是想知道为什么会这样?
PHP 7.2.9版
here 国家: