x = m * 10^e(except we use base 2 rather than base 10)
Exponent is excess-127 (single) or excess-1023 (double)
Magnitude is unsigned binary fraction (why unsigned?)
If exponent is not zero, mantissa is interpreted as having a leading 1
E.g.
1 10000111 01000000000000000000000This is a negative number (sign is 1)
Exponent is 135-127=8
Mantissa is 1*2-2 = 0.25
Value is: -1.25 * 2^8 = -320
Largest number:
0 11111111 11111111111111111111111Positive sign
Maximum exponent (255-127=128)
Maximum mantissa (1-2^-23)
Value is: (1+1-2^-23) * 2^128 = 6.81 * 10^38.
Or at least, this would be the largest IEEE single if the exponent 11111111 was not treated in a special way.
Bit patterns (+INF and -INF):
0 11111111 00000000000000000000000 1 11111111 00000000000000000000000Operations are well-defined on infinities:
Used to indicate "meaningless" operations
E.g.
Operating on a NaN usually results in the same NaN as the result.
1.100110011001100110011001 * 2^-126Divide this number by 2, and exponent becomes -127 (smallest possible). Divide by 2 again, and the number becomes
0.1100110011001100110011001 * 2^-127I.e. the leading bit is now 0, but we cannot reduce the exponent any further.
Happens when the exponent is larger than 23
With floats in the upper-end of the range, the distance reaches 2*10^31. E.g. in this range, x+1,000,000 still equals x.
E.g. represent 0.1 as a float
Closest single-precision IEEE float is
0.000110011001100110011001101but this is more like
0.10000000149These "minor" differences compound with each operation. Eventually, all precision can be lost.
Degradation is delayed by computing with high-precision (e.g. Extended floats), but the problem never goes away.