note 97758 deleted from function.dechex by danbrown
| From: | danbrown@php.net | Date: | Thu, 06 May 2010 15:54:12 +0000 |
| Subject: | note 97758 deleted from function.dechex by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169021@lists.php.net to get a copy of this message | ||
Note Submitter: Rosberg - rosberglinhares at gmail dot com
----
Here is a BC Math version:
function bcdechex($dec) {
static $dechex = array("0", "1", "2", "3",
"4", "5", "6", "7", "8", "9",
"A", "B", "C", "D", "E", "F");
$hex = "";
do {
$hex = $dechex[(int)bcmod($dec, 16)] . $hex;
$dec = bcdiv($dec, 16);
} while (bccomp($dec, 1) >= 0); // $dec >= 1
return $hex;
}