#46297 [Opn->Bgs]: Round Issue
| From: | derick@php.net | Date: | Wed, 15 Oct 2008 07:45:05 +0000 |
| Subject: | #46297 [Opn->Bgs]: Round Issue | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129708@lists.php.net to get a copy of this message | ||
ID: 46297
Updated by: derick@php.net
Reported By: rob at washeretoo dot com
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: Linux
PHP Version: 5.2.6
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:
------------------------------------------------------------------------
[2008-10-15 05:19:16] rob at washeretoo dot com
Description:
------------
round (1125.005, 2)
returns "1125.01" as expected
round(11125.005, 2)
returns "11125"
when the value before the decimal point gets to large it simply
strips the decimal point value off!??
Reproduce code:
---------------
print round (1125.005, 2);
print round(11125.005, 2);
Expected result:
----------------
round(11125.005, 2) should return 11125.01
Actual result:
--------------
round(11125.005, 2) returns 11125
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46297&edit=1