ID:               37642
 Updated by:       [EMAIL PROTECTED]
 Reported By:      richard at besite dot nl
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Linux and Windows XP
 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-05-30 09:41:45] richard at besite dot nl

Description:
------------
The calculation of this simple piece goes wrong:
3 * 1.35 - 4.05
Under Linux it gives: 8.881784197E-16
Under Windows it gives: 8.8817841970013E-016

Tested under Linux with: PHP4 4.4.2-1+b1 (Debian package php4 4.4.2-1),
PHP5 5.1.2-1+b1 (Debian package php5 5.1.2-1), PHP5 5.1.2 (Ubutu package
php5 5.1.2-ubuntu3).
Tested under Windows with: PHP4 4.4.2, PHP5 5.1.4, PHP5 snapshot
(5.2.0-dev of 05/30/2006), PHP6 snapshot (6.0.0 dev of 05/30/2006
8:30).

Btw, "3 * 1.36 - 4.08 == 0" returns true like you would expect.

Reproduce code:
---------------
<?php
var_dump( 3 * 1.35 - 4.05 == 0 );
print( 3 * 1.35 - 4.05 );
?>

Expected result:
----------------
bool(true)
0

Actual result:
--------------
bool(false)
8.881784197E-16


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


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

Reply via email to