Hardware Reference
In-Depth Information
to deal only with numbers that can be represented in a fixed number of digits. We
call such numbers finite-precision numbers .
In order to study properties of finite-precision numbers, let us examine the set
of positive integers representable by three decimal digits, with no decimal point
and no sign. This set has exactly 1000 members: 000, 001, 002, 003, ..., 999. With
this restriction, it is impossible to express certain kinds of numbers, such as
1. Numbers larger than 999.
2. Negative numbers.
3. Fractions.
4. Irrational numbers.
5. Complex numbers.
One important property of arithmetic on the set of all integers is closure with
respect to the operations of addition, subtraction, and multiplication.
In other
words, for every pair of integers i and j , i+j , i
j are also integers. The
set of integers is not closed with respect to division, because there exist values of i
and j for which i / j is not expressible as an integer (e.g., 7/2 and 1/0).
Finite-precision numbers are not closed with respect to any of these four basic
operations, as shown below, using three-digit decimal numbers as an example:
600 + 600 = 1200
j , and i
×
(too large)
003
005 =
2
(negative)
050 = 2500 (too large)
007 / 002 = 3.5 (not an integer)
The violations can be divided into two mutually exclusive classes: operations
whose result is larger than the largest number in the set (overflow error) or smaller
than the smallest number in the set (underflow error), and operations whose result
is neither too large nor too small but is simply not a member of the set. Of the four
violations above, the first three are examples of the former, and the fourth is an ex-
ample of the latter.
Because computers have finite memories and therefore must of necessity per-
form arithmetic on finite-precision numbers, the results of certain calculations will
be, from the point of view of classical mathematics, just plain wrong. A calculat-
ing device that gives the wrong answer even though it is in perfect working condi-
tion may appear strange at first, but the error is a logical consequence of its finite
nature. Some computers have special hardware that detects overflow errors.
The algebra of finite-precision numbers is different from normal algebra. As
an example, consider the associative law:
a
050
×
c
Let us evaluate both sides for a
+
( b
c )
=
( a
+
b )
=
700, b
=
400, c
=
300. To compute the left-hand
 
Search WWH ::




Custom Search