Bug #68111 [Opn]: json_decode introduces floating point precision error
| From: | ryan at ryanparman dot com | Date: | Sat, 27 Sep 2014 05:05:07 +0000 |
| Subject: | Bug #68111 [Opn]: json_decode introduces floating point precision error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187731@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68111&edit=1
ID: 68111
User updated by: ryan at ryanparman dot com
Reported by: ryan at ryanparman dot com
Summary: json_decode introduces floating point precision
error
Status: Open
Type: Bug
-Package: Scripting Engine problem
+Package: JSON related
Operating System: OS X
PHP Version: 5.5.17
Block user comment: N
Private report: N
New Comment:
This should be filed under JSON-related.
Previous Comments:
------------------------------------------------------------------------
[2014-09-27 05:00:56] ryan at ryanparman dot com
Description:
------------
When decoding a JSON string with json_decode(), a floating point precision error gets introduced.
Issue identified in PHP 5.5.17, and verified that it does NOT occur in 5.4.33.
Test script:
---------------
$data = json_decode('{"value": 4565.85}');
echo $data->value;
Expected result:
----------------
I expected
$data->value to have a value of 4565.85.
Actual result:
--------------
The actual value of $data->value is 4565.8500000000004.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68111&edit=1