IEEE 754中有多少个整数

编程入门 行业动态 更新时间:2024-10-28 10:25:48
本文介绍了IEEE 754中有多少个整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我试图找出在ieee 754中存在多少个不同的整数。我得到的数字是1778384895,但我找不到任何资源来检查我自己。 非常感谢。

解决方案

我会假设单精度浮点数。

我们得到了零,虽然可以表示为负零,但仍然只是零作​​为一个整数,所以我把它算为一个。

指数小于127的数字不是整数。

指数空位#数字 127 0 1 128 1 2 129 2 4 ... 149 22 2 ^ 22

这些总和为 2 ^ 23-1 。如果指数大于149,所有的数字都是整数。所以这是一个额外的 105 * 2 ^ 23 数字(指数255是保留的)。所有这些都是正面的和负面的。 总计是 pre $ 1 +((2 ^ 23-1)+ 105 *(2 ^ 23))* 2 = 1778384895

所以看起来你是对的。很好的问题,乍看起来很容易:)

I am trying to figure out how many different whole numbers exist in the ieee 754. The number I got was 1778384895 but I couldn't find any resource to check myself. Thanks a lot in advance.

解决方案

I will assume single precision floats.

We got the zero, which although can be represented as negative zero, is still just zero as an integer so I count it as one.

Numbers with exponent less than 127 are not integers.

Exponent Free bits # Numbers 127 0 1 128 1 2 129 2 4 ... 149 22 2^22

These sum up to 2^23-1. If exponent is greater than 149, all the numbers are integers. So that's an additional 105*2^23 numbers (exponent 255 is reserved). All of these come in positive and negative.

The grand total is thus

1 + ((2^23 - 1) + 105 * (2^23)) * 2 = 1778384895

So looks like you were right. Nice question, it looked a lot easier at first sight :)

更多推荐

IEEE 754中有多少个整数

本文发布于:2023-10-20 13:09:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1511060.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中有   整数   多少个   IEEE

发布评论

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

>www.elefans.com

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