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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 11:01:31 2025 UTC