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

 ID:               51480
 Updated by:       [email protected]
 Reported by:      vinilazev at gmail dot com
 Summary:          Error on calculation 100.2 - 100.1 - 0.1
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          Math related
 Operating System: Linux
 PHP Version:      Irrelevant

 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:
------------------------------------------------------------------------
[2010-04-05 16:43:18] vinilazev at gmail dot com

Description:
------------
Error on a simple calculation.



The correct result must be zero.



Google and JavaScript are wrong too.



But OpenOffice Calc and GCalcTool (gnome calculator) are correct.

Test script:
---------------
//Try a simple calculation:

$result = 100.2 - 100.1 - 0.1;

echo $result;

//The result is 8.520961714E-15



//And trying (inverting):

$result = 100.2 - 0.1 - 100.1;

echo $result;

//The result is 1.42108547152E-14

Expected result:
----------------
The correct result must be zero!

Actual result:
--------------
8.520961714E-15 and 1.42108547152E-14 respectively.


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



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

Reply via email to