php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38908 big NEGATIVE integers won't overflow on Linux
Submitted: 2006-09-21 04:14 UTC Modified: 2006-09-28 11:43 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: golikov at hotmail dot com Assigned:
Status: Closed Package: Variables related
PHP Version: 5.1.6 OS: Linux (2.6.9-34.0.2.ELsmp)
Private report: No CVE-ID: None
 [2006-09-21 04:14 UTC] golikov at hotmail dot com
Description:
------------
If big negative number (-3032250090012579) is converted to integer, php 5.1.6 does not overflow on LINUX and uses max negative integer value (-2147483648) instead. Though on Windows it works as ok. Related bug #30315.


Reproduce code:
---------------
$a2 = 2224955379988029;
echo "$a2 => (int)" . (int)$a2 . "\n";
$a3 = -2224955379988029;
echo "$a3 => (int)" . (int)$a3 . "\n";


Expected result:
----------------
2.224955379988E+015 => (int)-888097219
-2.224955379988E+015 => (int)888097219


Actual result:
--------------
2.22495537999E+15 => (int)-888097219
-2.22495537999E+15 => (int)-2147483648


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-28 11:43 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Sep 15 12:01:26 2019 UTC