From: tyokoo at monadel dot com dot au
Operating system: Windows2003R2 Standard
PHP version: 5.2.5
PHP Bug Type: Math related
Bug description: Wrong Result Adding Float (2.8 not 2.8)
Description:
------------
If you assign 2.8 on PHP you get:
2.79999999999999982236431605997495353221893310546875
if you do:
$n = 2.8;
$n = $n+$n+$n+$n+$n+$n+$n+$n+$n+$n;
and compare:
$n == 28
will be false.
2.8 is 2.8.
Nothing more or less.
Reproduce code:
---------------
$n = 2.8;
echo serialize($n).'<br />';
$n = $n+$n+$n+$n+$n+$n+$n+$n+$n+$n;
if ($n == 28) {
echo 'right';
} else {
echo 'wrong';
}
Expected result:
----------------
d:2.8;
right
Actual result:
--------------
d:2.79999999999999982236431605997495353221893310546875;
wrong
--
Edit bug report at http://bugs.php.net/?id=43640&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=43640&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=43640&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=43640&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=43640&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43640&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=43640&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43640&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43640&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43640&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43640&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43640&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=43640&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=43640&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43640&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43640&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43640&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43640&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43640&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43640&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43640&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43640&r=mysqlcfg