Bug #81553 [Opn->Nab]: json_encode PHP_INT_MAX

From: Date: Mon, 25 Oct 2021 12:52:27 +0000
Subject: Bug #81553 [Opn->Nab]: json_encode PHP_INT_MAX
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237358@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81553&edit=1 ID: 81553 Updated by: cmb@php.net Reported by: khaledalam dot net at gmail dot com Summary: json_encode PHP_INT_MAX -Status: Open +Status: Not a bug Type: Bug Package: Unknown/Other Function PHP Version: 8.0.12 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This has nothing to do with json_(en|de)code[1], but rather with var_dump() which uses serialize_precision instead of precision as of PHP 8.0.0[1]. [1] <https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.standard> Previous Comments: ------------------------------------------------------------------------ [2021-10-25 12:10:12] khaledalam dot net at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=81553&edit=1

« previous php.bugs (#237358) next »