note 68986 added to function.hexdec

From: Date: Fri, 18 Aug 2006 08:44:18 +0000
Subject: note 68986 added to function.hexdec
Groups: php.notes 
Request: Send a blank email to php-notes+get-116036@lists.php.net to get a copy of this message
Function converting HEX to signed DEC function hex2sdec ($hex) { //how many bytes $ib = strlen ($hex) - (strlen ($hex) % $hex)) / $hex; if ((strlen ($hex) % 2) > 0) $ib = $ib + 1; //how many bites $ibb = 8 * $ib; //search for -1 value (max_uj) $buf = '1'; for ($i = 1; $i <= $ibb - 1; $i++) { $buf .= '0'; } $max_uj = bindec ($buf); //decide a sign, and calculate a value if (hexdec ($hex) < $max_uj) //+ { $sdec = hexdec ($hex); } else //- { //search for max value + 1 //(for ex. if hex = 23ef then max_p1 = ffff + 1) $buf = ''; for ($i = 1; $i <= $ib; $i++) { $buf .= 'ff'; } $max_p1 = hexdec ($buf) + 1; $sdec = hexdec ($hex) - $max_p1; } return $sdec; } ---- Server IP: 83.64.128.68 Probable Submitter: 83.8.115.88 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.hexdec.php Edit -- https://master.php.net/note/edit/68986 Del: integrated -- https://master.php.net/note/delete/68986/integrated Del: useless -- https://master.php.net/note/delete/68986/useless Del: bad code -- https://master.php.net/note/delete/68986/bad+code Del: spam -- https://master.php.net/note/delete/68986/spam Del: non-english -- https://master.php.net/note/delete/68986/non-english Del: in docs -- https://master.php.net/note/delete/68986/in+docs Del: other reasons-- https://master.php.net/note/delete/68986 Reject -- https://master.php.net/note/reject/68986 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116036) next »