函数实现:
[Lua] 纯文本查看 复制代码 function float_i2f(bits)
local sign
local exponent
local mantissa
if((bits & 0x80000000) == 0) then
sign = 1
else
sign = -1
end
exponent = (bits & 0x7f800000)/(2^23)
mantissa = bits & 0x007fffff
mantissa = mantissa |0x00800000
f = sign * mantissa * 2^(exponent-150)
return f
end
print(float_i2f(0x45800000))
print(float_i2f(0x477fff00))
测下效果:
对应结果没问题:
|