Date: Tue, 4 Dec 2001 09:31:42 -0800
Reply-To: "William W. Viergever" <wwvierg@ATTGLOBAL.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "William W. Viergever" <wwvierg@ATTGLOBAL.NET>
Subject: FTMH: SAS Notes for 04Dec2001: Similar equations yield different
results on IEEE machines
Content-Type: multipart/alternative;
For the Mantissa-Heads:
> 006214 Similar equations yield different results on IEEE machines
> SN http://www.sas.com/service/techsup/unotes/SN/006/006214.html
SN-006214
Similar equations yield different results on IEEE machines
On IEEE platforms (including Windows), 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
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 an additional floating point store
instruction is executed, causing the result in the FPU to not be
discarded. The subtraction is performed, which results in the slight
difference in the generated result . The difference would be zero if
P was reloaded to an FPU prior to the subtraction.
The workaround is to specify the undocumented option NOCODEGEN.
Product:Base SAS
Component:SAS data sets (OS)
Priority:N/A
Status:Usage Issue
Date:Mon, 5 Nov 2001
SystemVersion ReportedVersion Fixed
AIX/6000 7 TSP1
Compaq Tru64 UNIX 7 TSP1
HP-UX Operating Systems 7 TSP1
IBM OS/2 7 TSP1
Solaris 7 TSP1
Windows NT 7 TSP1
Windows 95 7 TSP1
Windows 98 7 TSP1
Unless otherwise stated above, no fixes are available for this issue.
------------------------------------------------------------
William W. Viergever Voice : (916) 483-8398
Viergever & Associates Fax : (916) 486-1488
Sacramento, CA 95825 E-mail : wwvierg@attglobal.net
------------------------------------------------------------
[text/html]