ID:               26526
 Updated by:       [EMAIL PROTECTED]
 Reported By:      vince at blue-box dot net
-Status:           Open
+Status:           Bogus
 Bug Type:         Math related
 Operating System: FreeBSD 4.8-RELEASE-p13
 PHP Version:      4CVS-2003-12-04 (stable)
 New Comment:

Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.
 
Thank you for your interest in PHP.

# cat t.php 
<?php

ini_set('precision', 20);
$value = 6*.029*1000;
echo "value = $value\n";

?>

# php t.php 
value = 174.00000000000002842



Previous Comments:
------------------------------------------------------------------------

[2003-12-04 15:16:57] vince at blue-box dot net

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 this bug report at http://bugs.php.net/?id=26526&edit=1

Reply via email to