How do you determine how many integers are in set S of all in 32-bit IEEE floating-point values [duplicate]

戏子无情 提交于 2019-12-02 11:04:37

The finite positive floating-point numbers range from 2-149 (the smallest subnormal) to 2128-2104 (the number with the largest exponent for finite values and a significand of all one bits). We can group them into three categories:

  • The values less than 1. Zero of these are integers.
  • The values from 1 to 224-1. Some of these are integers, and some are not. However, every integer in this range is in the set of floating-point numbers, because they have at most 24 significant bits and are therefore representable with 24-bit significands. Therefore, the floating-point numbers have 224-1 integers in this interval.
  • The values from 224 and up. All of these are integers, because the least significant position in their significands represents at least 1. This range contains all floating point numbers with exponents (of two) from 24 to 127 and every allowed significand. The significands are all those starting with “1.” and followed by any 23 bits, so there are 223 significands. Therefore, there are (127-24+1)•223 of these numbers.

The total for positive integers is 0 + 224-1 + (127-24+1)*223. The number of negative integers is the same, and 0 adds one more, so the grand total is 1,778,384,895.

(Once we have found that number, it gives us a search key to find duplicate questions.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!