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

From: Date: Wed, 26 Sep 2018 08:53:43 +0000
Subject: Bug #76934 [NEW]: json encode bug php 7.1 and above
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217242@lists.php.net to get a copy of this message
From: grzesiek dot kesik at gmail dot com Operating system: any PHP version: 7.1.22 Package: JSON related Bug Type: Bug Bug description:json encode bug php 7.1 and above 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 bug report at https://bugs.php.net/bug.php?id=76934&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76934&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76934&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76934&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76934&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76934&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76934&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76934&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76934&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76934&r=support Expected behavior: https://bugs.php.net/fix.php?id=76934&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76934&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76934&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76934&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76934&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76934&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76934&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76934&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76934&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76934&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76934&r=mysqlcfg

« previous php.bugs (#217242) next »