From: sebastian dot sieburg at partyleader dot de Operating system: Linux, BSD, etc. .. PHP version: Irrelevant PHP Bug Type: Variables related Bug description: comparing 2 float variables with same value result false
Description: ------------ set a var using round, the other via value ... compare the vars .. same values but comparision returns false .. tried in php 4.3.1, 5.0.0-dev and 4.1.2 .. same problem in all versions .. Reproduce code: --------------- <?php $val = 1.11; echo "\$val: "; var_dump ($val); $p1 = $val * 100; $p2 = round ($val * 100); $p1 = (float)$p1; $p2 = (float)$p2; if ($p1 == $p2) echo "$p1 == $p2"; else echo "$p1 != $p2"; echo "\n"; echo "\$p1: "; var_dump ($p1); echo "\$p2: "; var_dump ($p2); ?> Expected result: ---------------- $val: float(1.11) 111 == 111 $p1: float(111) $p2: float(111) Actual result: -------------- $val: float(1.11) 111 != 111 $p1: float(111) $p2: float(111) -- Edit bug report at http://bugs.php.net/?id=25936&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25936&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25936&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25936&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25936&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25936&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25936&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25936&r=support Expected behavior: http://bugs.php.net/fix.php?id=25936&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25936&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25936&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25936&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25936&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25936&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25936&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25936&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=25936&r=float