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

Reply via email to