如何将23.5转换为二进制,使用1个字节作为尾数,1个字节作为指数(How to convert 23.5 into binary using 1 byte for the mantissa and

编程入门 行业动态 更新时间:2024-10-28 11:26:08
如何将23.5转换为二进制,使用1个字节作为尾数,1个字节作为指数(How to convert 23.5 into binary using 1 byte for the mantissa and 1 byte for the exponent)

我试过,这是我到目前为止所得到的:

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 ^ 100

Giving 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=00000100

But 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=10000100

The top mantissa (a.k.a. significand) bit is always 1, so it can be discarded, so now you have:

m=01111000 e=10000100

This is how I would store such a 16 bit floating binary point value.

更多推荐

本文发布于:2023-08-05 05:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428505.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字节   尾数   转换为   如何将   指数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!