#23780 [NEW]: Number comparision fails

From: Date: Fri, 23 May 2003 14:54:28 +0000
Subject: #23780 [NEW]: Number comparision fails
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40281@lists.php.net to get a copy of this message
From: walovaton at yahoo dot com dot mx Operating system: Linux PHP version: 4.3.1 PHP Bug Type: Variables related Bug description: Number comparision fails When I'm trying to compare two numbers, some times I get not expected results. Specially with float precision numbers. In my case: $value1 = 58.6; $value2 = 58.6; if ($value1 > $value2) { // PHP Bug! // This expresion seems to be true for some reason // The expected result is false, isn't it?? } This happens comparing the numbers as floats or as strings. It is important to say that $value1 is a value entered by the user into a form input (a validation number) and $value2 is the addition of several fields and such addition must be equal to $value1 in order to be accepted by the application. I hope this is clear enough for you. -William -- Edit bug report at http://bugs.php.net/?id=23780&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23780&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23780&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23780&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23780&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23780&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23780&r=support Expected behavior: http://bugs.php.net/fix.php?id=23780&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23780&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23780&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23780&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23780&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23780&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23780&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23780&r=gnused

« previous php.bugs (#40281) next »