32位浮点数的读取For a floating point value of 3.14159,the encoded 32-bit float value is 0x40490FD0.Modbus MSW = 0x4049Modbus LSW = 0x0FD0根据MSW和LSW怎么计算出值为3.14159

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 04:38:48
32位浮点数的读取For a floating point value of 3.14159,the encoded 32-bit float value is 0x40490FD0.Modbus MSW = 0x4049Modbus LSW = 0x0FD0根据MSW和LSW怎么计算出值为3.14159

32位浮点数的读取For a floating point value of 3.14159,the encoded 32-bit float value is 0x40490FD0.Modbus MSW = 0x4049Modbus LSW = 0x0FD0根据MSW和LSW怎么计算出值为3.14159
32位浮点数的读取
For a floating point value of 3.14159,the encoded 32-bit float value is 0x40490FD0.
Modbus MSW = 0x4049
Modbus LSW = 0x0FD0
根据MSW和LSW怎么计算出值为3.14159

32位浮点数的读取For a floating point value of 3.14159,the encoded 32-bit float value is 0x40490FD0.Modbus MSW = 0x4049Modbus LSW = 0x0FD0根据MSW和LSW怎么计算出值为3.14159
不清楚你那modbus源自什么.
但浮点数都需要参考ISO 754标准
值=(-1^符号位)*(1+i=1到23位的总和(b))*2^(指数-127)

0x 4049 0FD0.=0B 0100 0000 0100 1001 0000 1111 1101 0000
分段得 (0)(100 0000 0)(100 1001 0000 1111 1101 0000)
标志位 0,正数
指数100 0000 0 =128,减127后得1(根据ISO754定义127为0)
小数100 1001 0000 1111 1101 0000, 加1得浮点前数据
1.100 1001 0000 1111 1101 0000 ,小数点左移指数位1位,得
11.00 1001 0000 1111 1101 0000 ,逐位计算
(到这一步已经是电脑需要的答案了,下面为人类读十进制显示需要的)
=(2^1)+(2^0)+(2^-3)+(2^-6)+(2^-11)+(2^-12)+(2^-13)+(2^-14)+(2^-15)+(2^-16)+(2^-18)
=2+1+0.125+0.015625+0.00048828125+0.000244140625+...+(我用编程计算)
=3.141590118408203,得到近似值
由于32位浮点的精确值只有小数点前几位,所以一般标准输出环境只显示前5位
ps顺便自己复习一下.