我试过,这是我到目前为止所得到的:
10111.100 = 1.0111100 x 2 ^ 100为尾数提供10111100,为指数提供00000100,但我想我可能错了。
I tried and this is what i've got so far:
10111.100 = 1.0111100 x 2 ^ 100Giving 10111100 for the mantissa and 00000100 for the exponent, but i think i may have got it wrong.
最满意答案
23.5与47 x 2 ^ -1相同。 47是二进制00101111.现在简单地向右移动(并相应地递增指数),直到得到1.0111100和指数4(二进制00000100)。 我假设你对指数(可能是128)有某种偏见来迎合负指数,所以加上它。
换一种说法
23.5 = 47 * 2^-1 --> 00101111. exp -1 0010111.1 exp 0 001011.11 exp 1 00101.111 exp 2 0010.1111 exp 3 001.01111 exp 4 --> m=00101111 e=00000100但通常,这样的值被标准化以将顶部位设置为1:
1.01111000 exp 4.并且指数得到偏差,所以负值变为正值,比如128.加4,你得到:
e=10000100顶部尾数(又名有效数字)位始终为1,因此它可以被丢弃,所以现在你有:
m=01111000 e=10000100这就是我存储这样一个16位浮点二进制点值的方法。
23.5 is the same as 47 x 2^-1. 47 is binary 00101111. Now simply shift that right (and increment the exponent accordingly) until you get 1.0111100 and an exponent of 4 (binary 00000100). I assume you have some kind of bias for the exponent (probably 128) to cater for negative exponents, so add that.
In other words
23.5 = 47 * 2^-1 --> 00101111. exp -1 0010111.1 exp 0 001011.11 exp 1 00101.111 exp 2 0010.1111 exp 3 001.01111 exp 4 --> m=00101111 e=00000100But normally, such value are normalized to set the top bit to 1:
1.01111000 exp 4.And the exponent gets a bias, so negative values are turned into positive ones, say 128. Add 4 and you get:
e=10000100The top mantissa (a.k.a. significand) bit is always 1, so it can be discarded, so now you have:
m=01111000 e=10000100This is how I would store such a 16 bit floating binary point value.
更多推荐
发布评论