Page 16 - Compact Numerical Methods For Computers
P. 16
6 Compact numerical methods for computers
within the arithmetic of the system. Two programs in FORTRAN for determining the
machine precision, the radix or base of the arithmetic, and machine rounding or
truncating properties have been given by Malcolm (1972). The reader is cautioned
that, since these programs make use of tests of conditions like (1.3), they may be
frustrated by optimising compilers which are able to note that (1.3) in exact
arithmetic is equivalent to
eps>0. (1.4)
Condition (1.4) is not meaningful in the present context. The Univac compilers
have acquired some notoriety in this regard, but they are by no means the only
offenders.
To find the machine precision and radix by using arithmetic of the computer
itself, it is first necessary to find a number q such that (1 + q) and q are
represented identically, that is, the representation of 1 having the same exponent
as q has a digit in the (t + 1)th radix position where t is the number of radix digits
in the floating-point mantissa. As an example, consider a four decimal digit
machine. If q = 10,000 or greater, then q is represented as (say)
0.1 * 1E5
while 1 is represented as
0·00001 * 1E5.
The action of storing the five-digit sum
0·10001 * 1E5
in a four-digit word causes the last digit to be dropped. In the example,
q = 10 000 is the smallest number which causes (1 + q) and q to be represented
identically, but any number
q > 9999
will have the same property. If the machine under consideration has radix R, then
any t
q > R (1.5)
t +1
will have the desired property. If, moreover, q and R are represented so that
t +1
q < R (1.6)
then
q+R>q. (1.7)
In our example, R = 10 and t = 4 so the largest q consistent with (1.6) is
5
q = 10 -10 = 99 990 = 0·9999 * 1E5
and
99 990 + 10 = 100 000 = 0·1000 * 1E6 > q.
Starting with a trial value, say q = 1, successive doubling will give some number
k
q = 2