#39680 [NEW]: Type Casting from float into int
| From: | diefans at googlemail dot com | Date: | Wed, 29 Nov 2006 10:19:36 +0000 |
| Subject: | #39680 [NEW]: Type Casting from float into int | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-105614@lists.php.net to get a copy of this message | ||
From: diefans at googlemail dot com
Operating system: Linux
PHP version: 5.2.0
PHP Bug Type: *Math Functions
Bug description: Type Casting from float into int
Description:
------------
since version 5.2.0 when I cast a negative float smaller than -2147483648
into an int all bits are lost and the minimum Integer value is returned.
For positive floats larger than the max integer value all is fine.
It is not possible to perform bitwise calculations with negative
overflowing values since all usable information is lost.
Reproduce code:
---------------
echo (int) -40000000000;
echo (int) 40000000000;
Expected result:
----------------
-1345294336
1345294336
Actual result:
--------------
-2147483648
1345294336
--
Edit bug report at http://bugs.php.net/?id=39680&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39680&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39680&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39680&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39680&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39680&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39680&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39680&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39680&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39680&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39680&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39680&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39680&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39680&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39680&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39680&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39680&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39680&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39680&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39680&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39680&r=mysqlcfg