From tech-partners@wingra.adp.wisc.edu Fri Dec 23 12:52:42 1994 Date: Fri, 23 Dec 1994 12:52:58 -0600 Errors-To: owner-tech-partners@relay.adp.wisc.edu Reply-To: tech-partners@relay.adp.wisc.edu Originator: tech-partners@relay.adp.wisc.edu Sender: tech-partners@relay.adp.wisc.edu Precedence: bulk From: Anne Cooper To: Multiple recipients of list Subject: SAS' Pentium Position (fwd) -- in case it is of use... X-Listprocessor-Version: 6.0b -- ListProcessor by Anastasios Kotsikonas Forwarded message: >From owner-tsnews-l@VM.SAS.COM Fri Dec 23 12:08:20 1994 Message-Id: <199412231748.AA08572@mozart> Date: Fri, 23 Dec 1994 12:46:58 -0500 Reply-To: John Sims Sender: SAS Technical Support News for Customers From: John Sims Subject: SAS' Pentium Position To: Multiple recipients of list TSNEWS-L Intel Corporation has acknowledged a flaw in the floating point unit of their Pentium chip. Certain rare combinations of numbers in a floating point division (FDIV) will lead to a loss of precision in the result. To verify that your machine has a flawed Pentium chip, run the following SAS program and check the SAS Log for the results of the PUT statement: Data; x = 4195835; y = 3145727; z = x - (x/y) * y; if abs(z)>x*1e-14 then put 'error: ' _all_; else put 'ok'; run; The Pentium, which uses the IEEE 754 standard for floating point numbers, represents double-precision floating point numbers (the numbers used in the SAS DATA step and for non-integer computations in most SAS procedures) to a precision of about 15 decimal digits. The loss of precision due to the FDIV bug varies, but in the worst known cases the results are accurate to about 4 significant decimal digits. For example, 4195835/3145727 yields 1.333739... on a flawed Pentium, whereas the correct result is 1.333820... . The error can occur in any digit after the 4th, and seems to occur with equal frequency in the 6th and later digits, with errors in the 5th digit occurring half as often as in other digits. It is important to assess the precision in terms of significant digits, not in terms of decimal places, since the errors are relative in magnitude. Either number in the division can be multiplied by a power of two without changing the relative error. The FDIV bug occurs for about one in nine billion divisions with randomly selected numbers according to Intel. This assessment has been confirmed to within an order of magnitude by several people who are not associated with Intel. However, the values for which the bug occurs are not randomly or uniformly distributed. According to Tim Coe, 90% of the problem divisors fall within one of the following ranges multiplied by any integral power of two: 3.0 > divisor >= 3.0 - 36*(2**-22) 9.0 > divisor >= 9.0 - 36*(2**-20) 15.0 > divisor >= 15.0 - 36*(2**-20) 21.0 > divisor >= 21.0 - 36*(2**-19) 27.0 > divisor >= 27.0 - 36*(2**-19) The FDIV bug is believed not to occur for integer divisors less than 4000. However, the bug does happen with values that are just slightly less than an integer. An example from Vaughan R. Pratt shows that 4.999999/14.999999 yields 0.333329... on a flawed Pentium and 0.33333329... otherwise. Such values that are slightly less than an integer, which Pratt calls "bruised integers," can arise in floating point computations involving multiplication and division of integers and are a serious concern in situations where a large amount (such as 1E-8 or more) of bruising can occur. However, the SAS DATA step and most procedures use double-precision arithmetic, so the amount of bruising that occurs in typical calculations will rarely be more than 1E-12. According to Pratt's table, if the amount of bruising is less than 1E-12, the result is accurate to at least 10 significant digits. If you have a DATA step division involving a value that you know should be a small integer in exact arithmetic but that may have been bruised, you can use the ROUND function to make the value an exact integer. The risk to which SAS users are exposed due to the FDIV bug varies with the application. The greatest concern would attach to applications in which a high degree of precision is required in the results, such as many financial computations. The number of floating point divisions obviously should be considered, especially those in which the divisor is slightly less than an integer. Another concern would be whether numeric errors can be magnified during the computation. Many statistical applications involve only divisions by small integers, such as computing means and standard deviations of a sample of less than 4000 observations; in such cases there obviously is no risk. Many statistical computations involve few divisions. For example, computing the coefficients in a multiple regression on n predictors with PROC REG requires only n+1 divisions. As many as 60 additional divisions are required for each t statistic and p value, but the worst possible errors in probability computations are unlikely to show up in the customary 4 decimal places that SAS procedures print. On the other hand, PROC ORTHOREG does 6n divisions for every observation. Hence, the chance of encountering the FDIV bug is much greater with ORTHOREG than with REG. Numerical computations are described as "ill-conditioned" if a small numerical error can be magnified during the computation. An example is a multiple regression with highly correlated predictors. If the FDIV bug is encountered in PROC REG with uncorrelated predictors, the results are still likely to be accurate to at least three significant digits. If the predictors are highly correlated, it is possible that the error could be magnified to the point that some results have no accurate digits, but the more likely result is that the problem will incorrectly be declared singular. In either case, however, the error introduced by the FDIV bug is likely to be smaller than the statistical uncertainty. Computations involving discontinuous functions, such as subset regression or cluster analysis, are also ill-conditioned, since a small change in the input can produce a large change in the output. However, an error introduced by the FDIV bug is again likely to be smaller than the statistical uncertainty. Computationally intensive procedures such as CALIS or MIXED are more likely than most procedures to encounter the FDIV bug simply because they require more floating point computation than most procedures. Most of these computationally intensive procedures do some form of nonlinear optimization. An FDIV error that occurs during a nonlinear optimization is likely to be corrected at a later stage of the computation. Hence these procedures are probably at little more risk of producing incorrect final results than are noniterative procedures such as REG. RANUNI should not be affected by the FDIV bug since it has only one floating point division, and the divisor, 2**31-1, is not considered at risk. Neither should RANEXP, RANNOR, RANTBL, or RANTRI be affected. However, RANBIN, RANCAU, and RANGAM do contain divisions that could conceivably be affected. To obtain a crude assessment of the risk of an FDIV error of practical significance in statistical computations, we have rerun large parts of of the test libraries for the SAS/ETS, SAS/IML, SAS/OR, and SAS/STAT products on both Pentium and 486 machines. We failed to find any discrepancy greater than what would normally be expected due to numerical error. A few inconsequential differences could be attributed to the Pentium's greater accuracy in some transcendental functions. Version 6.10 of the SAS System for the PC was built with a compiler designed to take full advantage of improvements in the 486 and Pentium processors. Examples of these optimizations include instruction scheduling (re-arranging instructions to allow for more concurrent execution) and instruction pairing (selective use of instructions that have improved performance on this class of processors). These optimizations have no effect on the likelihood of SAS users encountering the FDIV bug in the Pentium processor. SAS Institute is vitally interested in the integrity of the results produced by its products. We would recommend that users who receive error results from the program listed above contact Intel's Customer Service at 800/628-8686 for information on obtaining a corrected Pentium chip.