Bug #13339 Updated: sscanf returns wrong result

From: Date: Sun, 07 Jul 2002 16:38:13 +0000
Subject: Bug #13339 Updated: sscanf returns wrong result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-13385@lists.php.net to get a copy of this message
ID: 13339 Updated by: derick@php.net Reported By: dev@generalprotectionfault.de -Status: Open +Status: Closed Bug Type: Variables related Operating System: Windows NT 4.0 PHP Version: 4.0.6 New Comment: $x = pow(2,32)-1; var_dump ($x) will give this: float(4294967295) Which is not an integer, and thus the value can be larger than +(2^31 -1) Anyway, this is not a bug, so closing. Derick Previous Comments: ------------------------------------------------------------------------ [2001-09-18 02:35:11] derick@php.net This was my result (On linux): 7ffffff 4294967295 80000 ------------------------------------------------------------------------ [2001-09-18 02:34:17] derick@php.net Please use the Web system for answerring. User update: You said php4 uses signed integers, so please explain that: // - - - - - - - - - - - - - - - - - - list($x) = sscanf( 'ffffffff', '%x' ); printf("%x<br>",$x); $x = pow(2,32)-1; echo $x , "<br>"; $y = ( $x >> 16 ) & 0xFFFF ; $x &= 0xFFFF; printf("%x%x<br>",$y,$x); // - - - - - - - - - - - - - - - - - - Result: 7fffffff 4294967295 ffffffff ------------------------------------------------------------------------ [2001-09-17 05:53:29] derick@php.net This is not weird, PHP's int are signed integers. 0xac00000 is too large for that. Derick ------------------------------------------------------------------------ [2001-09-17 05:50:38] dev@generalprotectionfault.de I've tried this: list($x) = sscanf( 'ac100000', '%x' ); printf("%x",$x); And I got "7fffffff", weird. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=13339&edit=1

« previous php.bugs (#13385) next »