Range and Precision
Learn how the mantissa and exponent affect the range and precision of numbers
Introduction
The range of numbers that we can store and the precision of those numbers is affected by the way we split the total number of bits between the mantissa and the exponent.
In this section, we will learn how changing the number of bits assigned to each of these will affect the range and accuracy.
Range and Precision
As we have seen in the previous section, every number must be split into a mantissa and an exponent.
If we store a number using 32 bits, this could be split up in multiple different ways:
Mantissa | Exponent |
---|---|
24 bits | 8 bits |
16 bits | 16 bits |
8 bits | 24 bits |
The way we allocate bits between the mantissa and exponent has a direct impact on both the range and precision of the numbers that can be represented.
Impact on Range
The range refers to the smallest and largest numbers that can be stored.
If we allocate more bits to the exponent, we can represent a wider range of numbers.
However, increasing the exponent's bit allocation comes at the cost of fewer bits available for the mantissa, which may reduce precision.
Impact on Precision
Precision refers to the level of detail in representing a number.
For example, if we were storing pi (which is an infinite number), storing it as 3.14159265359 is much more precise than storing it as 3.141
The more bits assigned to the mantissa, the greater the precision, as more significant digits can be stored
However, increasing the mantissa's bit allocation comes at the cost of fewer bits available for the exponent, which will reduce the range of numbers that can be stored.