note 97293 deleted from function.hexdec by danbrown

From: Date: Thu, 06 May 2010 15:46:39 +0000
Subject: note 97293 deleted from function.hexdec by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169016@lists.php.net to get a copy of this message
Note Submitter: dorianj ---- 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: <?php 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; } ?>

« previous php.notes (#169016) next »