Bug #75561 [NEW]: Json_encode does not encode numbers properly
From: anantaramdas at outlook dot com
Operating system: Windows
PHP version: Irrelevant
Package: Reproducible crash
Bug Type: Bug
Bug description:Json_encode does not encode numbers properly
Description:
------------
I have PHP version 7.1.7
Test script:
---------------
$amount = 26000;
\Log::info("A: " . $amount);
$json = json_encode([
'amount' => $amount,
]);
\Log::info("J: " . $json);
Expected result:
----------------
Expected Behavior
Gives following output:
info log [13:26:42] LOG.info: A: 26000
info log [13:26:42] LOG.info: J: {"amount":26000}
Actual result:
--------------
Gives following output:
info log [13:26:42] LOG.info: A: 26000
info log [13:26:42] LOG.info: J: {"amount":25999.999999999996}
--
Edit bug report at https://bugs.php.net/bug.php?id=75561&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75561&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75561&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75561&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75561&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75561&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75561&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75561&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75561&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75561&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75561&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75561&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75561&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75561&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75561&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75561&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75561&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75561&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75561&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75561&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75561&r=mysqlcfg
Thread (3 messages)
- anantaramdas at outlook dot com