php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32305 ceil returns unexpected results
Submitted: 2005-03-15 05:16 UTC Modified: 2005-03-15 06:03 UTC
From: webmaster at ew3d dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.3.9 OS: CentOS 4.0
Private report: No CVE-ID: None
 [2005-03-15 05:16 UTC] webmaster at ew3d dot com
Description:
------------
I'm running the current RHEL rpm php 4.3.9 i386.






Reproduce code:
---------------
printf(ceil(0.05*100)/100); //Returns 0.05
printf(ceil(0.06*100)/100); //Returns 0.06
printf(ceil(0.07*100)/100); //Returns 0.08 <-- Wrong
printf(ceil(7));            //Returns 7
printf(ceil(0.08*100)/100); //Returns 0.08
printf(ceil(0.14*100)/100); //Returns 0.15 <-- Wrong
printf(ceil(0.21*100)/100); //Returns 0.21

Expected result:
----------------
0.05
0.06
0.07
7
0.08
0.14
0.21

Actual result:
--------------
0.05
0.06
0.08
7
0.08
0.15
0.21

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-15 06:03 UTC] rasmus@php.net
Please read:

http://php.net/manual/en/language.types.float.php

You are magnifying floating point errors.  No bug here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC