cunsigned long int pow1unsigned char a1unsigned char a2 unsigned char i; unsigned long int value=1; fori=0;ia2;i++ value=a1; return value;函数名称: UR_3hex2float功能描述: 三字节浮点数转化输入参数: low-
function pow1(a1, a2)
local value = 1
for i = 1, a2 do
value = value * a1
end
return value
end
function UR_3hex2float(low, middle, high)
local SignB = 0
local CmplSignB = 0
local temp
local mantissa
local val
mantissa = middle * 256 + low
if high >= 128 then
SignB = 1
high = high - 128
end
if high >= 64 then
high = 128 - high
CmplSignB = 1
end
if high > 16 and CmplSignB == 0 then
temp = 2 ^ (high - 16)
val = mantissa * temp
else
if CmplSignB == 1 then
temp = 16 + high
if temp >= 32 then
temp = 31
end
else
temp = 16 - high
end
val = mantissa / (pow1(2, temp))
end
if SignB == 1 then
val = -val
end
return val
end
``
原文地址: https://www.cveoy.top/t/topic/hBjV 著作权归作者所有。请勿转载和采集!