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
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: webmaster at ew3d dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Tue Oct 20 03:01:23 2020 UTC