#50970 [NEW]: force convert a string into int using (int) or intval() cause value truncate

From: Date: Tue, 09 Feb 2010 01:29:31 +0000
Subject: #50970 [NEW]: force convert a string into int using (int) or intval() cause value truncate
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-147350@lists.php.net to get a copy of this message
From: zhangsilly at gmail dot com Operating system: Windows XP PHP version: 5.2.12 PHP Bug Type: Scripting Engine problem Bug description: force convert a string into int using (int) or intval() cause value truncate Description: ------------ use (int) or intval() to convert a string into integer in userland, if bigger than 2147483647, this will result a truncate, the value will always be 2147483647. but use zend_parse_parameters to parse the string as a long arguement, is do give the correct value in nagtive format Reproduce code: --------------- /** * assert failure * (int)3740925952 result is -554041344 * (int)'3740925952' result is 2147483647 */ assert((int)3740925952 == (int)'3740925952'); Expected result: ---------------- assert should be succeed Actual result: -------------- assert failure -- Edit bug report at http://bugs.php.net/?id=50970&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50970&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50970&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50970&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50970&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50970&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50970&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50970&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50970&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50970&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50970&r=support Expected behavior: http://bugs.php.net/fix.php?id=50970&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50970&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50970&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50970&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50970&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50970&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50970&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50970&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50970&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50970&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50970&r=mysqlcfg

« previous php.bugs (#147350) next »