#34370 [Bgs]: intval fails on negative hex numbers

From: Date: Mon, 05 Sep 2005 10:18:07 +0000
Subject: #34370 [Bgs]: intval fails on negative hex numbers
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969369894@lists.php.net to get a copy of this message
ID: 34370 User updated by: andreybl at matrix dot co dot il Reported By: andreybl at matrix dot co dot il Status: Bogus Bug Type: Documentation problem Operating System: RH EL 3.0 PHP Version: 5CVS-2005-09-05 (snap) New Comment: Actually 0xffffffff is neither negative nor positive. It depends upon how we treat it: as signed or as unsigned. Ok. Should I close the bug? Previous Comments: ------------------------------------------------------------------------ [2005-09-05 10:57:11] vrana@php.net 0xffffffff isn't negative, it's 4294967295 which is over limit so 2147483647 is returned according to documentation. ------------------------------------------------------------------------ [2005-09-05 08:56:57] sniper@php.net Documentation should state this more clearly. ------------------------------------------------------------------------ [2005-09-05 00:32:29] andreybl at matrix dot co dot il Description: ------------ inval() for negative hex number returns the max integer value. Reproduce code: --------------- $hex1 = intval("0xffffffff", 16); $hex2 = intval("0x7fffffff", 16); var_dump($hex1, $hex2); Expected result: ---------------- int(-1) int(2147483647) Actual result: -------------- int(2147483647) int(2147483647) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34370&edit=1

« previous php.doc (#969369894) next »