|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-08-29 14:37 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2018-08-29 14:37 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 13:00:01 2025 UTC |
Description: ------------ If you execute the test script there is a difference in the binary representation: The first line will output: cdcccccccccc2640 The second line will output: cccccccccccc2640 The string representation both show 11.4. The comparison will say that the result of the first line is higher than the second line. But that is not true, they should be equal. This only seems to happen when you use 0.95 or 0.951. If you use 0.9511 or 0.94 the result is as expected (if you recalculate the expected result). If you use 0.951 the result is the same as with 0.95. This has been tested on both 5.6.37 and 7.1.21. Test script: --------------- var_dump(bin2hex(pack('d', 11.4))); var_dump(bin2hex(pack('d', 0.95*12))); if(11.4 > 0.95*12) { echo 'It\'s bigger'; } else { echo 'It\'s the same or lower';//Should echo this, but it will echo It's bigger } Expected result: ---------------- It's the same or lower should be echo-ed. Actual result: -------------- It's bigger will be echo-ed