|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75700 Incorrect number after json_encode
Submitted: 2017-12-17 18:30 UTC Modified: 2017-12-20 20:34 UTC
From: admin at twister-vl dot ru Assigned:
Status: Not a bug Package: JSON related
PHP Version: 7.2.0 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
44 - 13 = ?
Subscribe to this entry?

 [2017-12-17 18:30 UTC] admin at twister-vl dot ru
Some numbers after json_encode may contain unexpected zeros.

Test script:
$a =  (1010*(0.00003*100))/100;

echo $a;
echo "\n";
echo json_encode($a);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-20 20:28 UTC]
-Package: json +Package: JSON related
 [2017-12-20 20:34 UTC]
-Status: Open +Status: Not a bug
 [2017-12-20 20:34 UTC]
The actual result is correct, please see

If you'd like to receive the old result (though you should ask yourself why you want that) you can either
a) change the serialize_precision setting, understanding that you will no longer receive an accurate floating-point representation, or
b) explicitly round your floating point numbers to a lower level of precision.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Feb 07 16:03:54 2023 UTC