Bug #65420 [Opn->Nab]: Comparison with double values wrong
| From: | rasmus@php.net | Date: | Thu, 08 Aug 2013 10:44:58 +0000 |
| Subject: | Bug #65420 [Opn->Nab]: Comparison with double values wrong | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-180800@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65420&edit=1
ID: 65420
Updated by: rasmus@php.net
Reported by: g dot karagyozov at gmail dot com
Summary: Comparison with double values wrong
-Status: Open
+Status: Not a bug
Type: Bug
Package: Apache related
Operating System: OSX
PHP Version: 5.5.1
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:
------------------------------------------------------------------------
[2013-08-08 08:52:19] g dot karagyozov at gmail dot com
Description:
------------
Comparison with some double values is not correct.
Test script:
---------------
var_dump(1.8 > (1.9 - 0.1));
var_dump(1.1 > (1.2 - 0.1));
Expected result:
----------------
false expected
Actual result:
--------------
true returned
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65420&edit=1