php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51274 Integer overflow does not cast as float
Submitted: 2010-03-11 15:15 UTC Modified: 2012-01-30 13:32 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: cduncan at regatta dot com Assigned: aharvey (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
 [2010-03-11 15:15 UTC] cduncan at regatta dot com
Description:
------------
The manual (http://php.net/manual/pl/language.types.integer.php) includes the following segment to cover integer overflow:

<?php
$large_number =  2147483647;
var_dump($large_number);
// output: int(2147483647)

$large_number =  2147483648;
var_dump($large_number);
// output: float(2147483648)
?>

However when I try this on my recently upgraded server they are both output as int(2147483647)

Test script:
---------------
$large_number =  2147483647;
var_dump($large_number);

$large_number =  2147483648;
var_dump($large_number);


Expected result:
----------------
I expect to see;

int(2147483647)
float(2147483648)

As I do on my box running 5.3.1


Actual result:
--------------
int(2147483647)
int(2147483647)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-11 17:58 UTC] [email protected]
-Status: Open +Status: Feedback -Package: Unknown/Other Function +Package: *General Issues
 [2010-03-11 17:58 UTC] [email protected]
Could it possibly be that you're running this on 64bit machine? :)
 [2010-03-11 19:05 UTC] cduncan at regatta dot com
64bit machine, 32bit OS.
Also, wouldn't we expect a 64bit to return:

int(2147483647)
int(2147483648)
 [2010-03-26 06:21 UTC] ssufficool at gmail dot com
64 bit ubuntu 10.04 PHP 5.3 SVN:
int(2147483647)
int(2147483648)

32 bit machine and OS PHP 5.2.10:
int(2147483647)
float(2147483648)
 [2010-03-26 06:33 UTC] [email protected]
-Status: Open +Status: Feedback
 [2010-03-26 06:33 UTC] [email protected]
I can't really see any way this could occur other than your server
having a 64-bit install of Linux on it. What distribution is the
server running, what does "uname -m" output, and what does configure
say the host and target system types are?

(Side note: the manual could admittedly be a bit clearer on this;
although the fact integer size differs on different platforms is
mentioned, it might be useful if the Integer Overflow section
actually reiterated it. I'll see about updating it.)
 [2010-03-26 07:50 UTC] [email protected]
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=296829
Log: Update to the integer type page to make it clearer how overflow works on 32-
and 64-bit systems and what the critical thresholds are. Prompted by
bug #51274, although not an actual fix for it.
 [2010-03-26 09:16 UTC] cduncan at regatta dot com
Sorry but I'm misunderstanding what you are telling me. Why is the number reduced to the 32bit limit? (2147483647)

Especially if you're saying the only way this could occur is with a 64bit OS?

As I stated in my last edit, wouldn't a 64bit OS return:
int(2147483648)
 [2010-03-26 09:24 UTC] [email protected]
-Status: Feedback +Status: Open
 [2010-03-26 09:24 UTC] [email protected]
Oh, I see what you're getting at now. Sorry about that.

I still can't reproduce it, though.
 [2010-03-26 10:17 UTC] cduncan at regatta dot com
Thanks, I was worried I was going mad for a moment there.

Unfortunately I can't reproduce it on the machines I'm using at the moment. The machine I was experiencing it on was a production box, so finding time to reproduce it again could be tricky.

Once I am able to do so, what extra information would assist in tracking this down?

Thanks
 [2010-04-13 16:42 UTC] cduncan at regatta dot com
I am now able to reproduce the problem, what extra information do you require to debug?
 [2010-04-23 22:56 UTC] [email protected]
-Package: *General Issues +Package: Scripting Engine problem
 [2010-06-08 14:56 UTC] [email protected]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: aharvey
 [2010-07-28 09:31 UTC] cduncan at regatta dot com
This seems to be resolved in 5.3.3

When I upgraded to 5.3.3 I was unable to reproduce the problem
 [2012-01-30 13:32 UTC] [email protected]
Cleaning up my old bugs (not that I'm sure how this was assigned to me in the 
first place). Since nobody has complained since 5.3.3, I guess we'll call this 
fixed. Somehow.
 [2012-01-30 13:32 UTC] [email protected]
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 25 18:00:01 2025 UTC