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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jan-php at kantert dot net
New email:
PHP Version: OS:

 

 [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-2022 The PHP Group
All rights reserved.
Last updated: Tue Sep 27 02:05:53 2022 UTC