Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
863 views
in Technique[技术] by (71.8m points)

assembly - how many whole numbers in IEEE 754

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...