#46879 [NEW]: Float addition not always precise
| From: | php at thwien dot de | Date: | Tue, 16 Dec 2008 11:24:06 +0000 |
| Subject: | #46879 [NEW]: Float addition not always precise | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-132022@lists.php.net to get a copy of this message | ||
From: php at thwien dot de
Operating system: Linux-Debian 4.0
PHP version: 5.2CVS-2008-12-16 (snap)
PHP Bug Type: Variables related
Bug description: Float addition not always precise
Description:
------------
Float comparison after addition isn't precise always.
Reproduce code:
---------------
$floatTotal = 19.99 + 39.99;
print ($floatTotal - 59.98);
Expected result:
----------------
0
Actual result:
--------------
7.105427357601E-15
--
Edit bug report at http://bugs.php.net/?id=46879&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46879&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46879&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46879&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46879&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46879&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=46879&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46879&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46879&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46879&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46879&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46879&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46879&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46879&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46879&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46879&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46879&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46879&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46879&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46879&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46879&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46879&r=mysqlcfg