Floating point numbers - accuracy v range
Imagine that you have ten boxes in which to represent a denary number in scientific notation. You have to decide how many places to allow for the sign, how many for the mantissa and how many for the exponent. The choices that you make will affect the range and accuracy of the numbers you can hold. Let's look at some examples to see what we mean. Let us invent a system for storing the digits of a scientific number. Suppose we decide on the following system, where each box can hold one number:
What is the biggest number it can hold?
What happens if you want to represent a really massive exponent, e.g. 345 in the number 0.45 x 10345?
You can't, because you have only allowed two places for the exponent. By allowing only two places for the exponent, we are limiting the size (and range) of the numbers we can represent.
What happens if you want to represent a number with a very accurate mantissa e.g. 0.4992999472 in the number 0.4992999472 x 1015?
You can't, using our current system, because we have only allowed 8 places for the mantissa. By doing this, we have limited the accuracy of the numbers we can hold even though we can hold the exponent in this example. We would have to round any numbers that need a mantissa of more than 8 places.
Of course, you can decide to allow 3 places for the exponent. That means you will only have 7 places for the mantissa. What is the result of this? It means we can represent much bigger numbers (up to an exponent of 999) but less accurate numbers (up to 0.999999 this time). Conversely, we could allow just one place for the exponent and 9 places for the mantissa. That means we are really limiting the range of numbers we can represent (an exponent of only 109) but now we can represent numbers with a much greater accuracy, to 0.99999999
The same argument can be applied to binary numbers. You will always have a fixed number of bits, perhaps 2 bytes (16 bits) for example. You need to make a decision about what the range of numbers is going to be. What will be the smallest number you need to represent and what will be the largest? This will guide you in deciding how many bits you need for the exponent. You also need to decide how accurate you need the number you're storing. In other words, how many decimal places you want for the number. This will help you decide how many bits to allow for the mantissa.