Bug #76934 [Opn->Nab]: json encode bug php 7.1 and above
| From: | requinix@php.net | Date: | Wed, 26 Sep 2018 08:55:34 +0000 |
| Subject: | Bug #76934 [Opn->Nab]: json encode bug php 7.1 and above | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217243@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76934&edit=1
ID: 76934
Updated by: requinix@php.net
Reported by: grzesiek dot kesik at gmail dot com
Summary: json encode bug php 7.1 and above
-Status: Open
+Status: Not a bug
Type: Bug
Package: JSON related
Operating System: any
PHP Version: 7.1.22
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
http://php.net/manual/en/function.json-encode.php
> Changelog
> 7.1.0 serialize_precision is used instead of precision when encoding double values.
http://php.net/manual/en/ini.core.php#ini.serialize-precision
Check your serialize_precision setting.
Previous Comments:
------------------------------------------------------------------------
[2018-09-26 08:53:43] grzesiek dot kesik at gmail dot com
Description:
------------
After some calculation json_encode encounter problem with casting numbers
Test script:
---------------
<?php
$n1 = 9.79;
$n2 = $n1 *100;
echo $n1;
echo ' ';
echo $n2;
echo ' ';
echo json_encode($n2);
echo ' ';
$n3 = 979;
echo json_encode($n3);
Expected result:
----------------
echo json_encode($n2);
should be equals 979
Actual result:
--------------
echo json_encode($n2);
is equal 978.9999999999999
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76934&edit=1