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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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-2022 The PHP Group
All rights reserved.
Last updated: Sun Aug 14 18:05:43 2022 UTC