Floating point numbers are used to represent numbers which:
Consider a very large number, such as 4,567,390. What if you only were allowed to use 4 decimal places to represent this number? You really need 7 places, but you can only have 4. Which places will you choose to keep? Which will you throw away? The most important thing about a number is its magnitude. When we are forced to drop digits because we have no room to store them, we will always drop the least significant ones and keep the most significant ones. So, for 4,567,390 we will keep the '4,567' and throw away the ',390'. We must remember, however, that this number is '4 million 567 thousand' rather than '4 thousand 567.' So we can write our original number like this:
This will require us to keep an additional number, which is the power of ten to be multiplied by the 4 digits we chose to remember. Using this scheme we are able to store large numbers in small spaces. The price is precision.. We have truncated 4,567,390 to 4,567,000. By throwing away the '390' we have reduced the precision of the number, but kept the most important information, given the amount of space we are allowed to use to store it. A truncated number is also known as an "approximate" representation of the actual number.
Not all of the digits we write in a number are significant. In the above number (4,567,000) we know that only the first four digits are significant because we are the ones that chopped off the 390. But consider the number:
How many digits are significant in this number? Certainly the '8' and the '4' are significant. In fact, all non-zero digits are significant. But what about the last two 0's? If this is exactly the number '8,400' then all four digits are significant. However, if this number was originally '8,425' and it has been trunctated to fit into 2 digits, then the last two digits are not significant. This is an ambiguous representation for this number, since we don't know whether the trailing zeros are significant. We will have to deal with the ambiguity problem shortly.
You can't always throw away 0's. Consider
The three 0's in the middle are important because they separate the '7' from the '1', and the '1' does contribute to the accuracy of the number. Zeros are significant when they appear between other significant digits.
Consider the number 00,780. The two leading zeros contribute no information to the number. In fact, we can write any number with as many leading zeros as we wish and it will never make any difference. Therefore, leading zeros (zeros that come before all the other significant digits) are never significant, even if they are after a decimal point.
Speaking of decimal points, adding decimal points can make things confusing. Consider the number
You may first think that only the '3' and the '4' are significant. However, the fact that the '0' appears may be important. It could be saying 'We measured this number to the nearest hundredth, and it just happens to be 0.' In this case, the accuracy of the number (that it was measured to the nearest hundredth) is significant, and the 0 is significant. So, trailing zeros that appear after an embedded decimal point and other significant digits are also significant.
So, given a number, here are the rules for determining which digits are significant:
Here are several examples of numbers, with the significant digits underlined:
The ambiguous cases are difficult to work with, so we need a way to write numbers which leaves no room for doubt about which digits are and are not significant. This can be accomplished by writing the number in two parts. The first part is the signficant digits, and the second part is the power of the base to multiply by. So, if we take '4,567,390' and truncate it to 4 digits, we would write it as:
4,567 x 103
This format, known as exponential form, shows us that there are 4 significant digits, but that this number is 4,567,000. Exponential form just breaks the number down into two parts:
There are several possible exponential form representations of the same number which vary in where the decimal point is placed, which determines the exponent value. For example, the above number could also have been written as any of the following (two of which are special forms):
456.7 x 104
45.67 x 105
4.567 x 106 - scientific notation
.4567 x 107 - normalized exponential form
Although these are equivalent representations, for practical purposes we should choose a normalized form. A normalized form is one where the decimal point is forced to a particular position. There are two normalized forms in use. One, simply called normalized exponential form forces the decimal point to the left of the most significant digit. Another, which we will use, is called scientific notatation, in which the decimal point is forced to go to the right of the most significant digit.
All of what we have learned about precision of decimal numbers applies to binary numbers, too. Consider the binary number 01001011. If you were only allowed 4 bits of precision, how would you represent this number. First, you would isolate the significant bits, which would be 01001011. Next, you would keep the first four significant digits and throw away the rest. So, this number becomes 1001000 which could be written in scientific notation as:
1.001 x 10110
Remember that this is all written in binary, so the above would be read "one point oh oh one times two to the sixth." Here's another example: 0.001011011 stored in 6 bits. The six most significant bits are 0.001011011. Written in scientific notation:
1.01101 x 10-11
Remember, that's two raised to the minus third power!
Previous Module: Computer Integer Arithmetic
Next Section: Floating-point Representation
Return to Module Index