#33030 [NEW]: Floating point subtraction : incorrect precision

From: Date: Fri, 13 May 2005 20:59:14 +0000
Subject: #33030 [NEW]: Floating point subtraction : incorrect precision
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78987@lists.php.net to get a copy of this message
From: justandy at lagparty dot org Operating system: XP PHP version: 5CVS-2005-05-13 (dev) PHP Bug Type: Math related Bug description: Floating point subtraction : incorrect precision Description: ------------ PHP 5.0.0 (cli) (built: Jul 13 2004 21:39:58) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.0, Copyright (c) 1998-2004 Zend Technologies // Subtraction for floating point numbers is incorrect. I searched the existing bug reports and could not find anything similar. Running the same version on LINUX reports the correct value. Reproduce code: --------------- <? //CORRECT: 0.03 echo 1.06 - 1.03; //WRONG : 0.029999999999999 echo 6.06 - 6.03; ?> Expected result: ---------------- 0.03 Actual result: -------------- 0.029999999999999 -- Edit bug report at http://bugs.php.net/?id=33030&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33030&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33030&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33030&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33030&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33030&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33030&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33030&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33030&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33030&r=support Expected behavior: http://bugs.php.net/fix.php?id=33030&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33030&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33030&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33030&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33030&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33030&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33030&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33030&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33030&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33030&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33030&r=mysqlcfg

« previous php.bugs (#78987) next »