#41338 [NEW]: ceil() gives strange results
| From: | kjarli at gmail dot com | Date: | Wed, 09 May 2007 09:10:26 +0000 |
| Subject: | #41338 [NEW]: ceil() gives strange results | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-112435@lists.php.net to get a copy of this message | ||
From: kjarli at gmail dot com
Operating system: Windows vista
PHP version: 5.2.2
PHP Bug Type: Math related
Bug description: ceil() gives strange results
Description:
------------
when creating formulas, i encountered a strange bug:
this is the basic forumula:
ceil(user_hp * 1.1)
when user_hp = 100 you get the following formula
ceil(100*(110/100)) in my script.
this will result 111 instead of 110
Reproduce code:
---------------
<?php
$lol1 = ceil(100 * (110 / 100));
$lol2 = ceil(100 * 1.1);
$lol3 = ceil(110);
$lol4 = ceil(110.0);
echo $lol1;
?>
<br />
<?php
echo $lol2;
?>
<br />
<?php
echo $lol3;
?>
<br />
<?php
echo $lol4;
?>
Expected result:
----------------
110
110
110
110
Actual result:
--------------
111
111
110
110
--
Edit bug report at http://bugs.php.net/?id=41338&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41338&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41338&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41338&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41338&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41338&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41338&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41338&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41338&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41338&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41338&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41338&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41338&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41338&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41338&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41338&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41338&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41338&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41338&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41338&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41338&r=mysqlcfg