如何将十六进制 A67BFE427CBDC58F 转换为 int 64 签名 -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。这是正确的,但没有符号((如何将无符号转换为有符号?
PHP 5.3+;PHP_INT_SIZE == 4