note 97292 added to function.hexdec
| From: | dorianj at osu1 dot php dot net | Date: | Mon, 12 Apr 2010 21:43:30 +0000 |
| Subject: | note 97292 added to function.hexdec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-168177@lists.php.net to get a copy of this message | ||
Here's a considerably faster version of bchexdec, which converts numbers of arbitrary
precision. It's about 40% quicker than the other version on this page:
function bchexdec($hex)
{
static $hexdec =
array('0','1','2','3','4','5','6','7','8','9',
'a'=>'10','b'=>'11','c'=>'12','d'=>'13','e'=>'14','f'=>'15',
'A'=>'10','B'=>'11','B'=>'12','D'=>'13','E'=>'14','F'=>'15');
$dec = '0';
for ($i = $l = strlen($hex), $e = '1'; $i; $i--, $e = bcmul($e, '16'))
$dec = bcadd($dec, bcmul($hexdec[$hex[$i-1]], $e));
return $dec;
}
----
Server IP: 192.41.40.227
Probable Submitter: 70.135.68.190
----
Manual Page -- http://www.php.net/manual/en/function.hexdec.php
Edit -- https://master.php.net/note/edit/97292
Del: integrated -- https://master.php.net/note/delete/97292/integrated
Del: useless -- https://master.php.net/note/delete/97292/useless
Del: bad code -- https://master.php.net/note/delete/97292/bad+code
Del: spam -- https://master.php.net/note/delete/97292/spam
Del: non-english -- https://master.php.net/note/delete/97292/non-english
Del: in docs -- https://master.php.net/note/delete/97292/in+docs
Del: other reasons-- https://master.php.net/note/delete/97292
Reject -- https://master.php.net/note/reject/97292
Search -- https://master.php.net/manage/user-notes.php