Bug #72487 [Com]: 100 - 99.6 why result = 0.400000001

[email protected] ("wee_weerapat at hotmail dot com")
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=72487&edit=1

 ID:                 72487
 Comment by:         wee_weerapat at hotmail dot com
 Reported by:        wee_weerapat at hotmail dot com
 Summary:            100 - 99.6 why result = 0.400000001
 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:

Oh I see. Thank you so much.


Previous Comments:
------------------------------------------------------------------------
[2016-06-24 11:40:05] [email protected]

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.

.

------------------------------------------------------------------------
[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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.