php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4760 ceil() returns the same value as floor()
Submitted: 2000-06-01 18:21 UTC Modified: 2000-06-02 01:27 UTC
From: jakub dot soucek at spika dot cz Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.0 Release OS: WinNT 4 SP5
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: jakub dot soucek at spika dot cz
New email:
PHP Version: OS:

 

 [2000-06-01 18:21 UTC] jakub dot soucek at spika dot cz
Function ceil() returns the same value as floor(), i.e. ceil(9.7) = floor(9.7) = 9.
In PHP 3 this code works fine. When I try to replace decimal point with comma, I get error message (this seems to be correct).
I use Czech WinNT Workstation 4.0 with point as a decimal separator in regional settings, IIS 4.0 with PHP ISAPI module. I also tried to change the regional number settings so I don't think it is a problem of decimal separator.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-01 18:42 UTC] hholzgra at cvs dot php dot net
this is just another instance of the 
decimals/locale problem

using 9,7 instead of 9.7 will do it for your 
system/locale settings

future versions will always use . as delimiter
in sourcecode, regardless of locale
 [2000-06-01 18:46 UTC] hholzgra at cvs dot php dot net
didn't see the 2nd paragraph ... :(
... so i'll re-open it for now

but as ceil()/floor() work for me (4.0.0/linux)
could you please verify that it doesn't work
with ',' instead of '.' by changing the source
instead of system settings?



 [2000-06-01 18:51 UTC] hholzgra at cvs dot php dot net
now call me stupid ...
what i was trying to say this time was:

could you pleas try ceil("9,7")
or see what the result of  9.7 - 9 
is compared to 9,7 - 9
 [2000-06-01 19:34 UTC] jakub dot soucek at spika dot cz
You were right - 
ceil("9,2") gives me correct result (10), ceil("9.2") gives me 9. So when I use string parameter and choose correct decimal separator it works just fine. But it seems to me I cannot use float constant assignment.

Let's have this:
$f = $j * $i;
and assign $i and $j to
$i =         2.4       2,4       "2.4"       "2,4"
$j =         5.3       5,3       "5.3"       "5,3"             
ceil($f)     10        ERR        10           13
floor($f)    10        ERR        10           12

It probably is problem with the locale, but I must admit I am a bit confused. Or am I missing something obvious?


 [2000-06-01 19:42 UTC] jakub dot soucek at spika dot cz
now call ME stupid...

This is not a problem of ceil(), floor() but it is really just another instance of the decimals/locale problem as you said before. Excuse me.


 [2000-06-02 01:27 UTC] hholzgra at cvs dot php dot net
so i'll close it now
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC