ID:               38321
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ibexris at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Unknown/Other Function
 Operating System: Fedora Core
 PHP Version:      5.1.4
 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.

If you would like to know more about "floats" and what IEEE
754 is read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.




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

[2006-08-04 00:35:06] ibexris at gmail dot com

Description:
------------
I just got bitten by a float precision problem and ceil() that affects
several versions of php and definitely doesn't behave in a consistent
manner.  I've tested this on linux (x86 and x86_64) and OSX with the
same results, so I don't believe that it's dependent on the system
libraries.  You'll also notice that the problem goes away by rounding
the results below PHP's 14 digit float precision, and that it only
affects certain numbers (which made this rather hard to track down).

Reproduce code:
---------------
<?php
   $x = 1.2 * 100;
   echo "$x\n", ceil($x), "\n";
   $x = 1.1 * 100;
   echo "$x\n",
        ceil($x), "\n",
        ceil(round($x, 13)), "\n",
        ceil(round($x, 14)), "\n";
?>


Expected result:
----------------
120
120
110
110
110
110


Actual result:
--------------
120
120
110
111
110
111



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38321&edit=1

Reply via email to