php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63193 json_decode procudes wrong int values
Submitted: 2012-10-01 13:03 UTC Modified: 2012-10-02 15:26 UTC
From: jan dot winkler at adspirit dot de Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.2.6 OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jan dot winkler at adspirit dot de
New email:
PHP Version: OS:

 

 [2012-10-01 13:03 UTC] jan dot winkler at adspirit dot de
Description:
------------
the following code produces a wrong number when decoded:

$a = array('a'=>5584842151736052644);
$x = json_encode($a);
print_r(json_decode($x));

... will output stdClass Object ( [a] => 5584842151736052736 ) instead of 5584842151736052644

Test script:
---------------
$a = array('a'=>5584842151736052644);
$x = json_encode($a);
print_r(json_decode($x));

Expected result:
----------------
json_decode should output stdClass Object ( [a] => 5584842151736052644 )

Actual result:
--------------
stdClass Object ( [a] => 5584842151736052736 )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-01 15:26 UTC] laruence@php.net
do you run with a 32-bit OS?
 [2012-10-01 15:31 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2012-10-01 15:49 UTC] rasmus@php.net
Works fine on 64-bit machines. Not much we can do about this.
 [2012-10-01 15:49 UTC] rasmus@php.net
-Status: Feedback +Status: Not a bug
 [2012-10-02 09:38 UTC] jan dot winkler at adspirit dot de
Here is php info:




Version 5.2.6
 




System 

Linux ds92-51-187-2 2.6.18-274.12.1.el5 #1 SMP Tue Nov 8 21:37:35 EST 2011 x86_64 



Build Date 

Aug 14 2008 12:38:42 



Configure Command 

'./configure' '--host=x86_64-redhat-linux-gnu' '--build=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux' '--prefix=/opt/HE' '--exec-prefix=/opt/HE' '--bindir=/opt/HE/bin' '--sbindir=/opt/HE/sbin' '--sysconfdir=/opt/HE/etc' '--datadir=/opt/HE/share' '--includedir=/opt/HE/include' '--libdir=/opt/HE/lib64' '--libexecdir=/opt/HE/libexec' '--localstatedir=/opt/HE/var' '--sharedstatedir=/opt/HE/com' '--mandir=/opt/HE/man' '--infodir=/opt/HE/info' '--with-libdir=lib64' '--with-config-file-scan-dir=/opt/HE/etc/php.d' '--with-config-file-path=/opt/HE/etc' '--disable-debug' '--enable-magic-quotes' '--enable-libxml' '--enable-session' '--enable-simplexml' '--enable-spl' '--enable-xml' '--enable-zend-multibyte' '--enable-filter' '--enable-libgcc' '--with-pcre-regex' '--enable-sigchild' '--with-regex=php' '--enable-inline-optimization' '--with-zlib' '--with-zlib-dir=/usr/lib64' '--with-apxs2' '--disable-all' '--disable-cli' 



Server API 

Apache 2.0 Handler 



Virtual Directory Support 

disabled 



Configuration File (php.ini) Path 

/opt/HE/etc 



Loaded Configuration File 

/opt/HE/etc/php.ini 



Scan this dir for additional .ini files 

/opt/HE/etc/php.d 



additional .ini files parsed 

/opt/HE/etc/php.d/curl.ini, /opt/HE/etc/php.d/exif.ini, /opt/HE/etc/php.d/ftp.ini, /opt/HE/etc/php.d/gd.ini, /opt/HE/etc/php.d/iconv.ini, /opt/HE/etc/php.d/json.ini, /opt/HE/etc/php.d/memcache.ini, /opt/HE/etc/php.d/mysql.ini, /opt/HE/etc/php.d/mysqli.ini, /opt/HE/etc/php.d/openssl.ini, /opt/HE/etc/php.d/pdo.ini, /opt/HE/etc/php.d/pdo_mysql.ini, /opt/HE/etc/php.d/rar.ini, /opt/HE/etc/php.d/soap.ini, /opt/HE/etc/php.d/sockets.ini, /opt/HE/etc/php.d/xcache.ini, /opt/HE/etc/php.d/zip.ini 



PHP API 

20041225 



PHP Extension 

20060613 



Zend Extension 

220060519 



Debug Build 

no 



Thread Safety 

disabled 



Zend Memory Manager 

enabled 



IPv6 Support 

enabled 



Registered PHP Streams 

php, file, data, http, ftp, compress.zlib, https, ftps, zip 



Registered Stream Socket Transports 

tcp, udp, unix, udg, ssl, sslv3, sslv2, tls 



Registered Stream Filters 

string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*, convert.iconv.* 


json
json support enabled 
json version 1.2.1
 [2012-10-02 09:38 UTC] jan dot winkler at adspirit dot de
-PHP Version: 5.3.17 +PHP Version: 5.2.6
 [2012-10-02 09:43 UTC] jan dot winkler at adspirit dot de
OS: 64 bit, redhat kernel 2.6.18-274.12.1.el5
 [2012-10-02 15:26 UTC] rasmus@php.net
That's a really old PHP. I tested your code on 5.3.x and 5.4.x and it works fine 
on 64-bit machines. I don't have a 2008 build around anywhere.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC