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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC