how convert hex A67BFE427CBDC58F to int 64 signed -6450282479763995249?
function bchexdec($hex) {
if(strlen($hex) == 1) {
return hexdec($hex);
} else {
$remain = substr($hex, 0, -1);
$last = substr($hex, -1);
$x = bcadd(bcmul(16, bchexdec($remain)), hexdec($last));
return $x;
}
bchexdec(‘A67BFE427CBDC58F’) == 11996461593945556367.
This correct, but without sign((
how convert unsigned to signed?
PHP 5.3+; PHP_INT_SIZE == 4
1 Answer