Bug #54414 [Opn->Bgs]: Floating-Point Arithmetic Bug
Edit report at http://bugs.php.net/bug.php?id=54414&edit=1
ID: 54414
Updated by: dtajchreber@php.net
Reported by: ejsexton82 at gmail dot com
Summary: Floating-Point Arithmetic Bug
-Status: Open
+Status: Bogus
Type: Bug
Package: Math related
Operating System: Windows Server 2003
PHP Version: 5.3.6
Block user comment: N
Private report: N
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://www.floating-point-gui.de/
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2011-03-28 20:57:06] ejsexton82 at gmail dot com
Description:
------------
The following calculation yields an unexpected result.
Test script:
---------------
$test = 625.0 - 661.7 + 37.0;
var_dump($test);
Expected result:
----------------
0.3
Actual result:
--------------
0.29999999999995
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54414&edit=1
Thread (2 messages)