According to the IEEE Std 754-2008 standard, the exponent field width of the binary64 double-precision floating-point format is 11 bits, which is compensated by an exponent bias of 1023. The standard also specifies that the maximum exponent is 1023, and the minimum is -1022. Why is the maximum exponent not:
2^10 + 2^9 + 2^8 + 2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0 - 1023 = 1024
And the minimum exponent not:
0 - 1023 = -1023
The bits for the exponent have two reserved values, one for encoding 0
and subnormal numbers, and one for encoding ∞ and NaNs. As a result of this, the range of normal exponents is two smaller than you would otherwise expect. See §3.4 of the IEEE-754 standard (w
is the number of bits in the exponent — 11
in the case of binary64
):
The range of the encoding's biased exponent E shall include:
― Every integer between 1 and 2w – 2, inclusive, to encode normal numbers
― The reserved value 0 to encode ±0 and subnormal numbers
― The reserved value 2w – 1 to encode ±∞ and NaNs.