Exponent bias
The floating point format of the IBM 704 introduced the use of a biased exponent in 1954.
In IEEE 754 floating point numbers, the exponent is biased in the engineering sense of the word – the value stored is offset from the actual value by the exponent bias. Biasing is done because exponents have to be signed values in order to be able to represent both tiny and huge values, but two's complement, the usual representation for signed values, would make comparison harder.
To solve this problem the exponent is stored as an unsigned value suitable for comparison, and when being interpreted it is converted to an exponent in a signed range by subtracting the bias.
By arranging the fields so that the sign bit is in the most significant bit position, the biased exponent in the middle, then the mantissa in the least significant bits, the resulting value will be ordered properly, whether it's interpreted as a floating point or integer value. This allows high speed comparisons of floating point numbers using fixed point hardware.
To calculate the bias for an arbitrarily sized floating point number apply the formula 2k−1 − 1 where k is the number of bits in the exponent.[1]
When interpreting the floating-point number, the bias is subtracted to retrieve the actual exponent.
- For a single-precision number, the exponent is stored in the range 1 .. 254 (0 and 255 have special meanings), and is biased by subtracting 127 to get an exponent value in the range −126 .. +127.
- For a double-precision number, the exponent is stored in the range 1 .. 2046 (0 and 2047 have special meanings), and is biased by subtracting 1023 to get an exponent value in the range −1022 .. +1023.
- For a quad-precision number, the exponent is stored in the range 1 .. 32766 (0 and 32767 have special meanings), and is biased by subtracting 16383 to get an exponent value in the range −16382 .. +16383.
See also
- Offset binary
- Excess-K
- Excess-15
- Excess-64
- Excess-127
- Excess-128
- Excess-129
- Excess-1023
- Excess-16383