如何将 IEEE 754 单精度浮点格式转换为十进制?

发布于 2024-08-23 22:59:06 字数 117 浏览 5 评论 0原文

我知道第一位是符号,接下来的 8 位是指数。那么在这个例子中你会有 1.1001*2^-4 吗?那么我该如何用十进制解释它呢?

0 01111011 10010000000000000000000

I understand that the first bit is the sign and that the next 8 bits is the exponent. So in this example you would have 1.1001*2^-4 ? How do I then interpret this in decimal?

0 01111011 10010000000000000000000

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

放飞的风筝 2024-08-30 22:59:06

因为您已经计算出这是(二进制)1.1001*10^-100,所以现在您只需将二进制数转换为十进制数即可。

在十进制中,每个数字的值是其前一位的十分之一。在二进制中,每个数字的值是前一位数字的一半。

首先 1.1001*10^-100 = 0.00011001。

这是...

  0 * 1           0 * 1
+ 0 * 1/2       + 0 * 0.5
+ 0 * 1/4       + 0 * 0.25
+ 0 * 1/8       + 0 * 0.125
+ 1 * 1/16      + 1 * 0.0625
+ 1 * 1/32      + 1 * 0.03125
+ 0 * 1/64      + 0 * 0.015625
+ 0 * 1/128     + 0 * 0.0078125
+ 1 * 1/256     + 1 * 0.00390625 

0.0625 + 0.03125 + 0.00390625 = 0.09765625

这就是它的全部内容。

Since you already figured out that this is (in binary)1.1001*10^-100, now you just have to convert the binary number to decimal.

In decimal, each digit has a value one-tenth as much as the one before it. In binary, each digit has a value one-half as much as the one before it.

First 1.1001*10^-100 = 0.00011001.

Which is...

  0 * 1           0 * 1
+ 0 * 1/2       + 0 * 0.5
+ 0 * 1/4       + 0 * 0.25
+ 0 * 1/8       + 0 * 0.125
+ 1 * 1/16      + 1 * 0.0625
+ 1 * 1/32      + 1 * 0.03125
+ 0 * 1/64      + 0 * 0.015625
+ 0 * 1/128     + 0 * 0.0078125
+ 1 * 1/256     + 1 * 0.00390625 

0.0625 + 0.03125 + 0.00390625 = 0.09765625

That's all there is to it.

究竟谁懂我的在乎 2024-08-30 22:59:06

1.1001b1*1 + 0.5*1 + 0.25*0 + 0.125*0 + 0.0625*11.5625。将其乘以 2**-4 (0.0625) 即可得到 0.09765625

1.1001b is 1*1 + 0.5*1 + 0.25*0 + 0.125*0 + 0.0625*1, or 1.5625. Multiply that by 2**-4 (0.0625) to get 0.09765625.

撕心裂肺的伤痛 2024-08-30 22:59:06

在C中:

int fl = *(int*)&floatVar;

in C:

int fl = *(int*)&floatVar;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文