Bug #81553 [NEW]: json_encode PHP_INT_MAX
| From: | khaledalam dot net at gmail dot com | Date: | Mon, 25 Oct 2021 12:10:12 +0000 |
| Subject: | Bug #81553 [NEW]: json_encode PHP_INT_MAX | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-237357@lists.php.net to get a copy of this message | ||
From: khaledalam dot net at gmail dot com
Operating system:
PHP version: 8.0.12
Package: Unknown/Other Function
Bug Type: Bug
Bug description:json_encode PHP_INT_MAX
Description:
------------
Getting different output values when use json_encode with big float
e.g. PHP_INT_MAX * PHP_INT_MAX
when use different php versions
https://3v4l.org/rBiTL
Test script:
---------------
<?php
$a = PHP_INT_MAX * PHP_INT_MAX;
$bb = json_encode($a, true);
$b = json_decode($bb);
var_dump($a);
var_dump($b);
Expected result:
----------------
same value regardless php version
float(8.507059173023462E+37)
or
float(8.5070591730235E+37)
Actual result:
--------------
Output for 8.0.0 - 8.0.12, 8.1rc1 - rc3
float(8.507059173023462E+37)
float(8.507059173023462E+37)
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.25
float(8.5070591730235E+37)
float(8.5070591730235E+37)
--
Edit bug report at https://bugs.php.net/bug.php?id=81553&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81553&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81553&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81553&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81553&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81553&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81553&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81553&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81553&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81553&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81553&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81553&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81553&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81553&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81553&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81553&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81553&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81553&r=mysqlcfg