A fixed point number system has a fixed number of total digits and a fixed number of fractional digits.

Such a system has a limited *range* (minimum
and maximum values) and *precision* (maximum
digits in any value, like significant figures in science).
As with any number set, the results of operations on two of the
numbers must also be within the set. This can sometimes yield
different results than we would see for an infinite number system.

**Example 14.1. A fixed-point system**

Suppose a system has 4 decimal digits, two of which are fractional. Then all numbers have the form ##.##.

The range is 00.00 to 99.99 and the precision is 4 decimal digits.

94.01 10.00 03.33 + 12.58 / 03.00 * 03.00 --------- --------- --------- 1 06.59 03.33 09.99

The sum above is 06.59, not the same as the 106.59 we get using real numbers.
We have to drop the '1' carried over from the addition of the leftmost
digits to fit within our fixed-point system. This is known as
*overflow*. Overflow can be detected either
by checking for a carry out of the leftmost digit, or by noting
that the sum is less than one of the terms being added.

The answer 10.00 / 03.00 = 03.33 is not as precise as we would
get using real numbers. Using real numbers, the result would be
3.33333... with the digits going on forever. In our fixed-point
system, we have to stop after 2 fractional digits and our
result is imprecise by 0.0033333...
This is commonly called *round-off* error,
though the correct term here is
*truncation* error. If a value is
rounded to the nearest true value, such as 20.00 / 3.00 = 6.67,
it is round-off error. If digits are simply lost, such as
20.00 / 3.00 = 6.66, it is truncation. Fixed point systems
typically suffer from truncation error, not round-off.

Note also that reversing the division by multiplying the result by 03.00 does not produce the original value of 10.00. In fact, the error in the result 0.33 (0.033333...) is multiplied by 3 along with the value itself, so the error in the final result of 0.99 is 0.01. This reveals a potential problem in computer programs that perform many calculations using limited number systems. The error can grow out of control unless we employ strategies to control it.

Define each of the following:

Range

Accuracy

Precision

What happens when the result of an arithmetic operation in a mathematical set such as integers or real numbers is outside the range of the fixed-point system we are using? Show an example using a 3-digit decimal system with 2 fractional digits.

What happens when the result of an arithmetic operation in a mathematical set such as integers or real numbers has more fractional digits than the fixed-point system we are using? Show an example using a 3-digit decimal system with 2 fractional digits.

Show the following computations in a fixed-point decimal system with 4 total digits and 1 fractional digit. Indicate whether overflow, round-off, or truncation occurs.

145.0 + 993.1

100.0 / 006.0

100.0 / 006.0 * 006.0