php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48939 ceil error
Submitted: 2009-07-16 05:11 UTC Modified: 2009-07-16 07:08 UTC
From: louis at frenzoo dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.2.10 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
36 - 11 = ?
Subscribe to this entry?

 
 [2009-07-16 05:11 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-16 06:36 UTC] 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 06:38 UTC] 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!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 20:01:32 2024 UTC