#30191 [Opn->Bgs]: sum error
| From: | johannes@php.net | Date: | Wed, 22 Sep 2004 06:10:06 +0000 |
| Subject: | #30191 [Opn->Bgs]: sum error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-66538@lists.php.net to get a copy of this message | ||
ID: 30191
Updated by: johannes@php.net
Reported By: roberto at spadim dot com dot br
-Status: Open
+Status: Bogus
Bug Type: *Math Functions
Operating System: linux, windows xp
PHP Version: 5.0.1
New Comment:
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
Thank you for your interest in PHP.
http://www.php.net/manual/en/language.types.float.php
Previous Comments:
------------------------------------------------------------------------
[2004-09-22 06:24:39] roberto at spadim dot com dot br
Description:
------------
sum error:
590-589.99!=0.01
Reproduce code:
---------------
<?php
echo 590-589.99;
echo "\n";
echo (double)(590)-(double)(589.99);
?>
Expected result:
----------------
0.01
0.01
Actual result:
--------------
0.0099999999999909
0.0099999999999909
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30191&edit=1