paranoia.1bk 6.4 KB

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