php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58003 Big numbers doesnt work
Submitted: 2008-01-11 13:18 UTC Modified: 2008-12-18 21:24 UTC
From: jan-php at kantert dot net Assigned:
Status: Closed Package: json (PECL)
PHP Version: 5.2.1 OS: Linux x86
Private report: No CVE-ID: None
 [2008-01-11 13:18 UTC] jan-php at kantert dot net
Description:
------------
Integers or floats bigger than 2 to the power 32 result in an overflow and dont work as expected. See the code below.

Reproduce code:
---------------
not working:
echo json_encode ( array ( 'number' => pow ( 2, 32 ) ) );
echo json_encode ( array ( 'number' => (int) pow ( 2, 32 ) ) );
echo json_encode ( array ( 'number' => (float) pow ( 2, 32 ) ) );

working:
echo json_encode ( array ( 'number' => (string) pow ( 2, 32 ) ) );

Expected result:
----------------
not working:
{"number":0}

working:
{"number":"4294967296"}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-18 21:24 UTC] scottmac@php.net
All of these are working correctly on 5.2.8 and 5.3.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 09:01:25 2019 UTC