|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73738 json_encode Digital precision problems
Submitted: 2016-12-14 14:07 UTC Modified: 2017-02-12 04:22 UTC
Avg. Score:4.4 ± 1.2
Reproduced:11 of 13 (84.6%)
Same Version:10 (90.9%)
Same OS:10 (90.9%)
From: chenjiablog at gmail dot com Assigned:
Status: No Feedback Package: json (PECL)
PHP Version: 7.1.0 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: chenjiablog at gmail dot com
New email:
PHP Version: OS:


 [2016-12-14 14:07 UTC] chenjiablog at gmail dot com
When using this function to deal with an array containing decimal, there will be precision problems.

Test script:
$array['a'] = "as";
$array['b'] = 1;
$array['c'] = 1.13;
$array['d'] = 10.08;
echo json_encode($array);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-30 16:42 UTC]
-Status: Open +Status: Feedback
 [2017-01-30 16:42 UTC]
this issue cannot be reproduced with your test script, see <>
 [2017-02-01 06:03 UTC] sergey at lutskanu dot ru, I confirm that this problem exists and reproduced both in 7.1.0 and 7.1.1.
About your example I think it can be specific behaviour on

To reproduce issue you can try it from CLI for example:

# cat test.php
$array['a'] = "as";
$array['b'] = 1;
$array['c'] = 1.13;
$array['d'] = 10.08;
echo json_encode($array);

# php -v
PHP 7.1.1 (cli) (built: Jan 18 2017 11:37:34) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.1, Copyright (c) 1999-2017, by Zend Technologies

# php test.php
 [2017-02-12 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Oct 02 17:05:52 2022 UTC