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
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:
21 - 6 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 15:01:30 2024 UTC