#26526 [NEW]: Unexpected behavior with ceil()
| From: | vince at blue-box dot net | Date: | Thu, 04 Dec 2003 20:16:57 +0000 |
| Subject: | #26526 [NEW]: Unexpected behavior with ceil() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-51702@lists.php.net to get a copy of this message | ||
From: vince at blue-box dot net
Operating system: FreeBSD 4.8-RELEASE-p13
PHP version: 4CVS-2003-12-04 (stable)
PHP Bug Type: Math related
Bug description: Unexpected behavior with ceil()
Description:
------------
When using certain integers derived from multiplying integers and floating
point numbers with ceil(), ceil() will increment the number even though it
shouldn't be.
Reproduce code:
---------------
<?php
$value = 6*.029*1000;
echo "value = $value\n";
$value = ceil($value);
echo "value = $value\n";
?>
Expected result:
----------------
Since 6*.029*1000 comes out to be exactly 174, I would expect the output
of the above script to be:
value = 174
value = 174
Actual result:
--------------
value = 174
value = 175
It seems like if this were a floating point precision problem the first
echo statement in the code example would produce something like:
value = 174.000000000000000000001
--
Edit bug report at http://bugs.php.net/?id=26526&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26526&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26526&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26526&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26526&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26526&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26526&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26526&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26526&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26526&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26526&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26526&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26526&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26526&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26526&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26526&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26526&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26526&r=float