This question already has an answer here:
-
how many whole numbers in IEEE 754
2 answers
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
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.)