Bug #68070 [Opn->Nab]: Wrong Answer to a fairly standard calculation
| From: | nikic@php.net | Date: | Mon, 22 Sep 2014 10:13:24 +0000 |
| Subject: | Bug #68070 [Opn->Nab]: Wrong Answer to a fairly standard calculation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187646@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68070&edit=1
ID: 68070
Updated by: nikic@php.net
Reported by: elliot at essentialsystems dot co dot uk
Summary: Wrong Answer to a fairly standard calculation
-Status: Open
+Status: Not a bug
Type: Bug
Package: Math related
Operating System: Ubuntu
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:
------------------------------------------------------------------------
[2014-09-22 10:10:04] elliot at essentialsystems dot co dot uk
Description:
------------
The calculation in the test script should return 34, but yet is returning back 33.999999999998,
which is very odd.
Test script:
---------------
<?php
//expecting 34
var_dump((40120.7 - 36346.0)-3740.7);
?>
Expected result:
----------------
Return back of the value of 34.
Actual result:
--------------
33.999999999998
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68070&edit=1