#41106 [NEW]: Simple Expression But Doing Wrong Calculation

From: Date: Mon, 16 Apr 2007 18:03:16 +0000
Subject: #41106 [NEW]: Simple Expression But Doing Wrong Calculation
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-111557@lists.php.net to get a copy of this message
From: neel dot basu dot z at gmail dot net Operating system: Windows PHP version: 5.2.1 PHP Bug Type: Math related Bug description: Simple Expression But Doing Wrong Calculation Description: ------------ Simple Expression but wrong output. Reproduce code: --------------- <?php $res1 = (1.2-0.1)-1.1;// = 1.1-1.1 -> Evaluates to Zero $res2 = (2.2-0.1)-2.1;// = 2.1-2.1 -> Also Evaluates to Zero echo $res1."\t".gettype($res1); echo "\n"; echo $res2."\t".gettype($res2); ?> Expected result: ---------------- 0 double 0 double Actual result: -------------- -2.22044604925E-016 double 0 double -- Edit bug report at http://bugs.php.net/?id=41106&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41106&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41106&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41106&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41106&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41106&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41106&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41106&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41106&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41106&r=support Expected behavior: http://bugs.php.net/fix.php?id=41106&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41106&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41106&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41106&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41106&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41106&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41106&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41106&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41106&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41106&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41106&r=mysqlcfg

« previous php.bugs (#111557) next »