Bug #72487 [Opn->Nab]: 100 - 99.6 why result = 0.400000001
| From: | rasmus@php.net | Date: | Fri, 24 Jun 2016 11:40:07 +0000 |
| Subject: | Bug #72487 [Opn->Nab]: 100 - 99.6 why result = 0.400000001 | ||
| References: | 1 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-1095@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72487&edit=1
ID: 72487
Updated by: rasmus@php.net
Reported by: wee_weerapat at hotmail dot com
Summary: 100 - 99.6 why result = 0.400000001
-Status: Open
+Status: Not a bug
Type: Bug
Package: PHP Language Specification
Operating System: Mac & Windows
PHP Version: 5.5.37
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:
------------------------------------------------------------------------
[2016-06-24 11:37:27] wee_weerapat at hotmail dot com
Description:
------------
I'm not sure. 100-99.6 the result will return 0.400000001
and i try many case 100 - 99.96 the result still same 0.040000000000006
There return another position of number
Test script:
---------------
echo 100-99.6;
echo "<br>";
echo 100-99.96;
echo "<br>";
echo 1000-999.96;
Expected result:
----------------
0.4
0.04
0.04
Actual result:
--------------
0.40000000000001
0.040000000000006
0.039999999999964
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72487&edit=1