Bug #76934 [Com]: json encode bug php 7.1 and above

From: Date: Wed, 26 Sep 2018 09:30:03 +0000
Subject: Bug #76934 [Com]: json encode bug php 7.1 and above
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217245@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 Comment by: grzesiek dot kesik at gmail dot com Reported by: grzesiek dot kesik at gmail dot com Summary: json encode bug php 7.1 and above 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: According to requinix@php.net comment, I have changed serialize_precision setting to 17 (as in php 7.0 http://php.net/manual/en/ini.list.php). For me it does not work. After restarting apache i still gets this rounding issue. Previous Comments: ------------------------------------------------------------------------ [2018-09-26 08:55:34] requinix@php.net 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#217245) next »