0

Could anybody explain to me what it is stating exactly? I know this basically means that it's single precision with 1bit sign, 8bit exponents and 23bit mantissa. Shouldn't the answer is just be 2 * 2^8-2 * 2^23?

Edit:does 2 * 2^8-2 * 2^23 determine all 32-bit IEEE floating-point values

Lawdevo
  • 29
  • 1
  • 7
  • Your proposed answer counts ALL floating-point values; the question asked for values that are *integers*. As a rough estimate, I'd say a bit less than half are integers - anything with an exponent < 0 cannot be an integer (unless it's zero), anything with an exponent >= 23 (size of mantissa) is definitely an integer. – jasonharper Oct 25 '17 at 06:10
  • Nvm figured it out, thanks for the help! really clarified things for me – Lawdevo Oct 25 '17 at 06:41

1 Answers1

5

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

Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312
  • 1
    The question is a duplicate, but your answer is way more clear then that in the original (e.g. you use the unbiased value for the exponent). – Bob__ Oct 25 '17 at 20:58
  • 1
    If one wants to know the number of bit patterns that are integers, one needs to count both positive and negative zeros. – Zalman Stern Oct 25 '17 at 23:22