#37642 [NEW]: 3 * 1.35 - 4.05 = 8.881784197E-16 but should be 0.0 (zero) (ALL versions!)

From: Date: Tue, 30 May 2006 09:41:45 +0000
Subject: #37642 [NEW]: 3 * 1.35 - 4.05 = 8.881784197E-16 but should be 0.0 (zero) (ALL versions!)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97790@lists.php.net to get a copy of this message
From: richard at besite dot nl Operating system: Linux and Windows XP PHP version: 5.1.4 PHP Bug Type: Scripting Engine problem Bug description: 3 * 1.35 - 4.05 = 8.881784197E-16 but should be 0.0 (zero) (ALL versions!) Description: ------------ The calculation of this simple piece goes wrong: 3 * 1.35 - 4.05 Under Linux it gives: 8.881784197E-16 Under Windows it gives: 8.8817841970013E-016 Tested under Linux with: PHP4 4.4.2-1+b1 (Debian package php4 4.4.2-1), PHP5 5.1.2-1+b1 (Debian package php5 5.1.2-1), PHP5 5.1.2 (Ubutu package php5 5.1.2-ubuntu3). Tested under Windows with: PHP4 4.4.2, PHP5 5.1.4, PHP5 snapshot (5.2.0-dev of 05/30/2006), PHP6 snapshot (6.0.0 dev of 05/30/2006 8:30). Btw, "3 * 1.36 - 4.08 == 0" returns true like you would expect. Reproduce code: --------------- <?php var_dump( 3 * 1.35 - 4.05 == 0 ); print( 3 * 1.35 - 4.05 ); ?> Expected result: ---------------- bool(true) 0 Actual result: -------------- bool(false) 8.881784197E-16 -- Edit bug report at http://bugs.php.net/?id=37642&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37642&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37642&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37642&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37642&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37642&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37642&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37642&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37642&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37642&r=support Expected behavior: http://bugs.php.net/fix.php?id=37642&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37642&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37642&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37642&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37642&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37642&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37642&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37642&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37642&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37642&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37642&r=mysqlcfg

« previous php.bugs (#97790) next »