Bug #74347 [Opn->Nab]: -1 - 0.1 + 1 + 0.1 bugg
| From: | requinix@php.net | Date: | Fri, 31 Mar 2017 09:18:42 +0000 |
| Subject: | Bug #74347 [Opn->Nab]: -1 - 0.1 + 1 + 0.1 bugg | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208210@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74347&edit=1
ID: 74347
Updated by: requinix@php.net
Reported by: stefan at van-echtelt dot nl
Summary: -1 - 0.1 + 1 + 0.1 bugg
-Status: Open
+Status: Not a bug
Type: Bug
Package: Output Control
Operating System: Windows
PHP Version: Irrelevant
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:
------------------------------------------------------------------------
[2017-03-31 09:17:42] stefan at van-echtelt dot nl
Description:
------------
$test = -1 - 0.1 + 1 + 0.1;
print $test;
if you print this in php the value will be -8.3266726846887E-17.
It should be 0.
Test script:
---------------
$test = -1 - 0.1 + 1 + 0.1;
print $test;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74347&edit=1