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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: louis at frenzoo dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 02:01:27 2025 UTC