首先問題是這樣的php
$x = 8 - 6.4; // which is equal to 1.6 $y = 1.6; var_dump($x === $y); // is not true echo "<br>"; var_dump(floatval($x) == floatval($y)); echo "<br>"; echo floatval($x) . "<br>"; echo floatval($y) . "<br>"; exit();
其實就是因爲$x變量在作減法運算後的小數精度和$y不一致致使的spa
看看PHP官方的說明.net
連接地址:http://php.net/manual/zh/language.types.float.php3d