Usage Note 6214: Similar equations yield different results on Intel machines
On Intel 32-bit platforms such as Windows and Linux, floating point unit (FPU) registers offer greater precision than floating point memory locations. It is not uncommon in C code for the same expression appearing in different parts of a program to produce slightly different results, because the compiler keeps intermediate results for a computation in the FPU registers. This permits a higher degree of precision, since the floating point register has 12 extra bits for the mantissa and 4 extra bits for the exponent. For example:
data _null_;
p=1;
p=p/100;
q=1;
q=q/100;
r=p-q;
put p= q= r=;
run;
produces:
p=0.01 q=0.01 r=2.083701E-19
The value of R is not exactly 0. Internally, P is loaded in an FPU
register and divided by 100. The result is written to memory, which
causes the processor to convert the value from an 80-bit to a 64-bit
floating point number. Q is then loaded and divided by 100. The result
is again written to memory but is also retained in the FPU. The
subtraction is then performed, using the stored 64-bit value for P and
the 80-bit retained value for Q, which results in the slight difference
in the generated result. The difference would be zero if Q was reloaded
to the FPU prior to the subtraction.
Operating System and Release Information
SAS System | Base SAS | Microsoft Windows 2000 Server | 8 TS M0 | |
Microsoft Windows 95/98 | 8 TS M0 | |
Microsoft Windows NT Workstation | 8 TS M0 | |
Linux | 8.2 TS2M0 | |
OS/2 | 8 TS M0 | |
Microsoft Windows 2000 Advanced Server | 8 TS M0 | |
Microsoft Windows 2000 Datacenter Server | 8 TS M0 | |
Microsoft Windows 2000 Professional | 8 TS M0 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Usage Note |
Priority: | |
Topic: | Data Management ==> Manipulation and Transformation ==> Numeric Precision SAS Reference ==> DATA Step
|
Date Modified: | 2012-07-06 13:15:23 |
Date Created: | 2001-11-05 15:30:03 |