|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-08-13 18:13 UTC] egdn2004 at gmail dot com
Description:
------------
Error when comparing floating point with two decimal places
Test script:
---------------
<?php
if (9.2 > 9.0 + 0.2) {
echo 'WRONG';
} else {
echo 'OK';
}
Expected result:
----------------
OK
Actual result:
--------------
WRONG
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 11:00:01 2025 UTC |
Test script: --------------- <?php $var1 = 9.22; $var2 = 9.20; $var_test = $var2 + 0.02; if ($var1 > $var_test) { echo "WRONG\n"; } else { echo "OK\n"; } if (9.22 > 9.20 + 0.02) { echo "WRONG"; } else { echo "OK"; } Expected result: ---------------- OK OK Actual result: -------------- WRONG WRONG