Bug #70261 [Opn]: Error when comparing floating point
Edit report at https://bugs.php.net/bug.php?id=70261&edit=1
ID: 70261
User updated by: egdn2004 at gmail dot com
Reported by: egdn2004 at gmail dot com
Summary: Error when comparing floating point
Status: Open
Type: Bug
Package: Reproducible crash
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2015-08-13 18:13:08] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70261&edit=1
Thread (3 messages)