|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14646 pow and floor misbehavior
Submitted: 2001-12-21 10:55 UTC Modified: 2001-12-21 11:37 UTC
From: reboot at gmx dot ch Assigned:
Status: Closed Package: Math related
PHP Version: 4.1.0 OS: Linux (Debian sid)
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.
Block user comment
Status: Assign to:
Bug Type:
From: reboot at gmx dot ch
New email:
PHP Version: OS:


 [2001-12-21 10:55 UTC] reboot at gmx dot ch
Executing this code:

print((      floor(7)  ==       floor(7.1) ) . "<BR>");
print((pow(2,floor(7)) == pow(2,floor(7.1))) . "<BR>");



So, if floor(7) is equal to floor(7.1) how can pow(2,x) from both numbers be different?

PHP 4.0.3pl1 gives the correct output 1<BR>1<BR>

Using the === to compare both non of the expressions is true, so i think floor and pow return int if the input is a integer, but the documentation says they always returns float. If i use 7.0 instead if 7 the output is correct and both expressions are equal.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-21 11:07 UTC]
Checking it out.
 [2001-12-21 11:08 UTC]
It works fine for me, on Debian Potato/PHP4.1.0/Apache1.3.22, and on Windows 2000 (with the same php/apache versions).
 [2001-12-21 11:15 UTC]
It's not bogus
 [2001-12-21 11:37 UTC]
Fixed in CVS. Floor() always returns a float now.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Sep 26 15:01:24 2023 UTC