#48939 [Csd->Bgs]: ceil error
| From: | scottmac@php.net | Date: | Thu, 16 Jul 2009 07:08:36 +0000 |
| Subject: | #48939 [Csd->Bgs]: ceil error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-139796@lists.php.net to get a copy of this message | ||
ID: 48939
Updated by: scottmac@php.net
Reported By: louis at frenzoo dot com
-Status: Closed
+Status: Bogus
Bug Type: Math related
Operating System: Linux
PHP Version: 5.2.10
Previous Comments:
------------------------------------------------------------------------
[2009-07-16 06:38:59] louis at frenzoo dot com
Sorry to disturb. Got the idea that it is the definition from IEEE, the
limitation of float in binary representation. Thanks for concern!
------------------------------------------------------------------------
[2009-07-16 06:36:47] kalle@php.net
Please try with PHP 5.3.0 where the rounding was revised per this RFC:
http://wiki.php.net/rfc/rounding
------------------------------------------------------------------------
[2009-07-16 05:11:52] louis at frenzoo dot com
Description:
------------
ceil() does not give an correct expected result.
I have read some bug reports before. I understand that there is
floating point error, but it happens in just a simple math calculation,
which is unacceptable in the below case. It created inaccurate result on
simple math, it will also create chaos in more complicated ones.
Reproduce code:
---------------
$n = 100.0*1.1;
print $n.'='.ceil($n);
Expected result:
----------------
110 = 110
Actual result:
--------------
110 = 111
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48939&edit=1