我会假设单精度浮点数。
我们得到了零,虽然可以表示为负零,但仍然只是零作为一个整数,所以我把它算为一个。
指数小于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^22These 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 = 1778384895So looks like you were right. Nice question, it looked a lot easier at first sight :)
更多推荐
IEEE 754中有多少个整数
发布评论