时间:2021-07-01 10:21:17 帮助过:36人阅读
function hexToDecFloat($strHex) {
$v = hexdec($strHex);
$x = ($v & ((1 << 23) - 1)) + (1 << 23) * ($v >> 31
------解决思路----------------------
1);
$exp = ($v >> 23 & 0xFF) - 127;
return $x * pow(2, $exp - 23);
}
$a='42C88000 ';
echo hexToDecFloat($a);
$s = '42C88000';100.25
echo current(unpack('f', pack('V', hexdec($s))));
$s = 'C1C90000';-25.125
echo current(unpack('f', pack('V', hexdec($s))));