ID:               49991
 Updated by:       sh...@php.net
 Reported By:      warren at guy dot net dot au
 Status:           Bogus
 Bug Type:         JSON related
 Operating System: FreeBSD 6.3
 PHP Version:      5.2.11
 New Comment:

FWIW, it works properly on my 32 bit linux machine (debian lenny):

$ php -v
PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009
22:16:23) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies


Previous Comments:
------------------------------------------------------------------------

[2009-10-25 20:19:43] j...@php.net

How exactly would it work when max int size on 32bit is 2147483647 ? 
Expected behaviour -> bogus.

------------------------------------------------------------------------

[2009-10-25 16:05:03] warren at guy dot net dot au

Nope, built on same machine it's running. 32 bit machine and OS.

FreeBSD [redacted] 6.3-RELEASE-p11 FreeBSD 6.3-RELEASE-p11 #0: Wed Jun
10 02:25:37 UTC 2009    
r...@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386

------------------------------------------------------------------------

[2009-10-25 16:00:18] matt...@php.net

Are you cross-compiling for 32-bit, on a 64-bit system...?

------------------------------------------------------------------------

[2009-10-25 13:33:59] warren at guy dot net dot au

Description:
------------
json_decode truncates numbers greater than 32 bit int 2147483647 on 32
bit system

Reproduce code:
---------------
<?

$json_encoded =
'{"test_id_small_int":12345,"test_id_maxint":2147483647,"test_id_maxint_plus_two":2147483649,"test_id_huge_int":80000000000}';

var_dump(json_decode($json_encoded));

?>


Expected result:
----------------
object(stdClass)#1 (4) {
  ["test_id_small_int"]=>
  int(12345)
  ["test_id_maxint"]=>
  int(2147483647)
  ["test_id_maxint_plus_two"]=>
  float(2147483649)
  ["test_id_huge_int"]=>
  float(80000000000)
}


or even strings instead of floats would work for me.

Actual result:
--------------
object(stdClass)#1 (4) {
  ["test_id_small_int"]=>
  int(12345)
  ["test_id_maxint"]=>
  int(2147483647)
  ["test_id_maxint_plus_two"]=>
  int(2147483647)
  ["test_id_huge_int"]=>
  int(2147483647)
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49991&edit=1

Reply via email to