1 |
58 |
fellnhofer |
Lest this program stop prematurely, i.e. before displaying
|
2 |
|
|
|
3 |
|
|
`END OF TEST',
|
4 |
|
|
|
5 |
|
|
try to persuade the computer NOT to terminate execution when an
|
6 |
|
|
error like Over/Underflow or Division by Zero occurs, but rather
|
7 |
|
|
to persevere with a surrogate value after, perhaps, displaying some
|
8 |
|
|
warning. If persuasion avails naught, don't despair but run this
|
9 |
|
|
program anyway to see how many milestones it passes, and then
|
10 |
|
|
amend it to make further progress.
|
11 |
|
|
|
12 |
|
|
Answer questions with Y, y, N or n (unless otherwise indicated).
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
Diagnosis resumes after milestone Number 0 Page: 1
|
16 |
|
|
|
17 |
|
|
Users are invited to help debug and augment this program so it will
|
18 |
|
|
cope with unanticipated and newly uncovered arithmetic pathologies.
|
19 |
|
|
|
20 |
|
|
Please send suggestions and interesting results to
|
21 |
|
|
Richard Karpinski
|
22 |
|
|
Computer Center U-76
|
23 |
|
|
University of California
|
24 |
|
|
San Francisco, CA 94143-0704, USA
|
25 |
|
|
|
26 |
|
|
In doing so, please include the following information:
|
27 |
|
|
Precision: double;
|
28 |
|
|
Version: 10 February 1989;
|
29 |
|
|
Computer:
|
30 |
|
|
|
31 |
|
|
Compiler:
|
32 |
|
|
|
33 |
|
|
Optimization level:
|
34 |
|
|
|
35 |
|
|
Other relevant compiler options:
|
36 |
|
|
|
37 |
|
|
Diagnosis resumes after milestone Number 1 Page: 2
|
38 |
|
|
|
39 |
|
|
Running this program should reveal these characteristics:
|
40 |
|
|
Radix = 1, 2, 4, 8, 10, 16, 100, 256 ...
|
41 |
|
|
Precision = number of significant digits carried.
|
42 |
|
|
U2 = Radix/Radix^Precision = One Ulp
|
43 |
|
|
(OneUlpnit in the Last Place) of 1.000xxx .
|
44 |
|
|
U1 = 1/Radix^Precision = One Ulp of numbers a little less than 1.0 .
|
45 |
|
|
Adequacy of guard digits for Mult., Div. and Subt.
|
46 |
|
|
Whether arithmetic is chopped, correctly rounded, or something else
|
47 |
|
|
for Mult., Div., Add/Subt. and Sqrt.
|
48 |
|
|
Whether a Sticky Bit used correctly for rounding.
|
49 |
|
|
UnderflowThreshold = an underflow threshold.
|
50 |
|
|
E0 and PseudoZero tell whether underflow is abrupt, gradual, or fuzzy.
|
51 |
|
|
V = an overflow threshold, roughly.
|
52 |
|
|
V0 tells, roughly, whether Infinity is represented.
|
53 |
|
|
Comparisions are checked for consistency with subtraction
|
54 |
|
|
and for contamination with pseudo-zeros.
|
55 |
|
|
Sqrt is tested. Y^X is not tested.
|
56 |
|
|
Extra-precise subexpressions are revealed but NOT YET tested.
|
57 |
|
|
Decimal-Binary conversion is NOT YET tested for accuracy.
|
58 |
|
|
|
59 |
|
|
Diagnosis resumes after milestone Number 2 Page: 3
|
60 |
|
|
|
61 |
|
|
The program attempts to discriminate among
|
62 |
|
|
FLAWs, like lack of a sticky bit,
|
63 |
|
|
Serious DEFECTs, like lack of a guard digit, and
|
64 |
|
|
FAILUREs, like 2+2 == 5 .
|
65 |
|
|
Failures may confound subsequent diagnoses.
|
66 |
|
|
|
67 |
|
|
The diagnostic capabilities of this program go beyond an earlier
|
68 |
|
|
program called `MACHAR', which can be found at the end of the
|
69 |
|
|
book `Software Manual for the Elementary Functions' (1980) by
|
70 |
|
|
W. J. Cody and W. Waite. Although both programs try to discover
|
71 |
|
|
the Radix, Precision and range (over/underflow thresholds)
|
72 |
|
|
of the arithmetic, this program tries to cope with a wider variety
|
73 |
|
|
of pathologies, and to say how well the arithmetic is implemented.
|
74 |
|
|
|
75 |
|
|
The program is based upon a conventional radix representation for
|
76 |
|
|
floating-point numbers, but also allows logarithmic encoding
|
77 |
|
|
as used by certain early WANG machines.
|
78 |
|
|
|
79 |
|
|
BASIC version of this program (C) 1983 by Prof. W. M. Kahan;
|
80 |
|
|
see source comments for more history.
|
81 |
|
|
|
82 |
|
|
Diagnosis resumes after milestone Number 3 Page: 4
|
83 |
|
|
|
84 |
|
|
Program is now RUNNING tests on small integers:
|
85 |
|
|
-1, 0, 1/2, 1, 2, 3, 4, 5, 9, 27, 32 & 240 are O.K.
|
86 |
|
|
|
87 |
|
|
Searching for Radix and Precision.
|
88 |
|
|
Radix = 2.000000 .
|
89 |
|
|
Closest relative separation found is U1 = 1.1102230e-16 .
|
90 |
|
|
|
91 |
|
|
Recalculating radix and precision
|
92 |
|
|
confirms closest relative separation U1 .
|
93 |
|
|
Radix confirmed.
|
94 |
|
|
The number of significant digits of the Radix is 53.000000 .
|
95 |
|
|
|
96 |
|
|
Diagnosis resumes after milestone Number 30 Page: 5
|
97 |
|
|
|
98 |
|
|
Subtraction appears to be normalized, as it should be.
|
99 |
|
|
Checking for guard digit in *, /, and -.
|
100 |
|
|
*, /, and - appear to have guard digits, as they should.
|
101 |
|
|
|
102 |
|
|
Diagnosis resumes after milestone Number 40 Page: 6
|
103 |
|
|
|
104 |
|
|
Checking rounding on multiply, divide and add/subtract.
|
105 |
|
|
Multiplication appears to round correctly.
|
106 |
|
|
Division appears to round correctly.
|
107 |
|
|
Addition/Subtraction appears to round correctly.
|
108 |
|
|
Checking for sticky bit.
|
109 |
|
|
Sticky bit apparently used correctly.
|
110 |
|
|
|
111 |
|
|
Does Multiplication commute? Testing on 20 random pairs.
|
112 |
|
|
No failures found in 20 integer pairs.
|
113 |
|
|
|
114 |
|
|
Running test of square root(x).
|
115 |
|
|
Testing if sqrt(X * X) == X for 20 Integers X.
|
116 |
|
|
Test for sqrt monotonicity.
|
117 |
|
|
sqrt has passed a test for Monotonicity.
|
118 |
|
|
Testing whether sqrt is rounded or chopped.
|
119 |
|
|
Square root appears to be correctly rounded.
|
120 |
|
|
|
121 |
|
|
Diagnosis resumes after milestone Number 90 Page: 7
|
122 |
|
|
|
123 |
|
|
Testing powers Z^i for small Integers Z and i.
|
124 |
|
|
... no discrepancis found.
|
125 |
|
|
|
126 |
|
|
Seeking Underflow thresholds UfThold and E0.
|
127 |
|
|
Smallest strictly positive number found is E0 = 2.22507e-308 .
|
128 |
|
|
Since comparison denies Z = 0, evaluating (Z + Z) / Z should be safe.
|
129 |
|
|
What the machine gets for (Z + Z) / Z is 2.00000000000000000e+00 .
|
130 |
|
|
This is O.K., provided Over/Underflow has NOT just been signaled.
|
131 |
|
|
|
132 |
|
|
Diagnosis resumes after milestone Number 120 Page: 8
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
FLAW: X = 3.05947655544740190e-308
|
136 |
|
|
is not equal to Z = 2.22507385850720140e-308 .
|
137 |
|
|
yet X - Z yields 0.00000000000000000e+00 .
|
138 |
|
|
Should this NOT signal Underflow, this is a SERIOUS DEFECT
|
139 |
|
|
that causes confusion when innocent statements like
|
140 |
|
|
if (X == Z) ... else ... (f(X) - f(Z)) / (X - Z) ...
|
141 |
|
|
encounter Division by Zero although actually
|
142 |
|
|
X / Z = 1 + 0.375 .
|
143 |
|
|
The Underflow threshold is 2.22507385850720140e-308, below which
|
144 |
|
|
calculation may suffer larger Relative error than merely roundoff.
|
145 |
|
|
Since underflow occurs below the threshold
|
146 |
|
|
UfThold = (2.00000000000000000e+00) ^ (-1.02200000000000000e+03)
|
147 |
|
|
only underflow should afflict the expression
|
148 |
|
|
(2.00000000000000000e+00) ^ (-1.02200000000000000e+03);
|
149 |
|
|
actually calculating yields: 0.00000000000000000e+00 .
|
150 |
|
|
This computed value is O.K.
|
151 |
|
|
|
152 |
|
|
Testing X^((X + 1) / (X - 1)) vs. exp(2) = 7.38905609893065220e+00 as X -> 1.
|
153 |
|
|
Accuracy seems adequate.
|
154 |
|
|
Testing powers Z^Q at four nearly extreme values.
|
155 |
|
|
... no discrepancies found.
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
Diagnosis resumes after milestone Number 160 Page: 9
|
159 |
|
|
|
160 |
|
|
Searching for Overflow threshold:
|
161 |
|
|
This may generate an error.
|
162 |
|
|
|
163 |
|
|
* * * FLOATING-POINT ERROR * * *
|
164 |
|
|
Can `Z = -Y' overflow?
|
165 |
|
|
Trying it on Y = -8.98846567431157950e+307 .
|
166 |
|
|
Seems O.K.
|
167 |
|
|
Overflow threshold is V = 1.79769313486231570e+308 .
|
168 |
|
|
There is no saturation value because the system traps on overflow.
|
169 |
|
|
No Overflow should be signaled for V * 1 = 1.79769313486231570e+308
|
170 |
|
|
nor for V / 1 = 1.79769313486231570e+308 .
|
171 |
|
|
Any overflow signal separating this * from the one
|
172 |
|
|
above is a DEFECT.
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
Diagnosis resumes after milestone Number 190 Page: 10
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
What message and/or values does Division by Zero produce?
|
179 |
|
|
Trying to compute 1 / 0 produces ...
|
180 |
|
|
* * * FLOATING-POINT ERROR * * *
|
181 |
|
|
|
182 |
|
|
Trying to compute 0 / 0 produces ...
|
183 |
|
|
* * * FLOATING-POINT ERROR * * *
|
184 |
|
|
|
185 |
|
|
Diagnosis resumes after milestone Number 220 Page: 11
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
No failures, defects nor flaws have been discovered.
|
190 |
|
|
Rounding appears to conform to the proposed IEEE standard P754,
|
191 |
|
|
except for possibly Double Rounding during Gradual Underflow.
|
192 |
|
|
The arithmetic diagnosed appears to be Excellent!
|
193 |
|
|
|
194 |
|
|
A total of 3 floating point exceptions were registered.
|
195 |
|
|
END OF TEST.
|