protected hex_to_dec ( $hex ) : string | ||
$hex | (string) hexadecimal number to convert specified as a string | |
return | string | hexadecimal representation |
protected function hex_to_dec($hex)
{
$dec = 0;
$bitval = 1;
$len = strlen($hex);
for ($pos = $len - 1; $pos >= 0; --$pos) {
$dec = bcadd($dec, bcmul(hexdec($hex[$pos]), $bitval));
$bitval = bcmul($bitval, 16);
}
return $dec;
}