#41907 [Opn->Bgs]: wrong result from round(64.365,2)
| From: | derick@php.net | Date: | Thu, 05 Jul 2007 16:30:05 +0000 |
| Subject: | #41907 [Opn->Bgs]: wrong result from round(64.365,2) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114680@lists.php.net to get a copy of this message | ||
ID: 41907
Updated by: derick@php.net
Reported By: milman at gmx dot de
-Status: Open
+Status: Bogus
Bug Type: *Math Functions
Operating System: windows xp
PHP Version: 5.2.3
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.
If you would like to know more about "floats" and what IEEE
754 is read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Thank you for your interest in PHP.
.
Previous Comments:
------------------------------------------------------------------------
[2007-07-05 16:27:24] milman at gmx dot de
Description:
------------
wrong result from round(64.365,2)
should be 64.37 not 64.36
Reproduce code:
---------------
<?
echo "right: round (63.365,2) = " . round (63.365,2) . "<br>\n" ;
echo "wrong: round (64.365,2) = " . round (64.365,2) . "<br>\n" ;
echo "wrong: round (81.365,2) = " . round (81.365,2) . "<br>\n" ;
echo "right: round (82.365,2) = " . round (82.365,2) . "<br>\n" ;
?>
Expected result:
----------------
allway .37 not somtimes .36
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41907&edit=1