We can develop a similar notation in binary.
Example:
001011001 = 1.011001 * 26
Since we know the base (
2
), we need to keep track of
- the sign (positive or negative)
- the significand (the significant digits, e.g.,
1011001
)- the exponent (e.g.,
6
)
Sign: 1 bit
Accuracy vs. Range
- If we give more bits to the significand, we have greater accuracy.
- If we give more bits to the exponent, we have greater range.
32-bit word
31 30 23 22 0 S Exp Significand ↑ 8 bits ↑ 23 bits Range is approx.
2.0 * 10-38 → 2.0 * 1038
64-bit word
63 62 52 51 0 S Exp Significand ↑ 11 bits ↑ 52 bits Range is roughly
2.0 * 10-308 → 2.0 * 10308
(bigger range and more accurate)Note: A number can be too big, but also too small.
Overflow: exponent too large
Underflow: negative exponent too large