Date: Fri, 22 Aug 2003 09:10:22 -0700
Reply-To: Paul Choate <pchoate@DDS.CA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Choate <pchoate@DDS.CA.GOV>
Subject: Re: Tiny Roundoff Errors in 8.2 for Windows
Content-Type: text/plain; charset=ISO-8859-1
Here is an idea - there is no error in the representation of integers,
as long as your magnitude is not huge (2^53 for 8 byte numbers in
Windows). If you work with your values as pennies rather than dollars
your arithmetic will always be exact.
DDS Data Extraction
topkatz@MSN.COM (Talbot Michael Katz) wrote in message news:<200308220252.h7M2qR707234@listserv.cc.uga.edu>...
> Hi, gang.
> I seem to be experiencing very small arithmetic roundoff errors in SAS 8.2
> for Windows. Here is the code snippet :
> run_bal = round(run_bal+tr_amount,0.01);
> bal_dif = run_bal - prod_balance;
> tr_amount = -bal_dif;
> if tr_amount ne round(tr_amount,0.01) then do;
> put "prec_num = " prec_num " tr_amount not round 27";
> end ;
> Note that run_bal is rounded to 0.01 (i.e., dollars and cents) at the top.
> Prod_balance has also been rounded to 0.01, so bal_dif should be, too.
> But, somehow, tr_amount = -bal_dif is off by about 10**(-12).
> Has anyone else experienced something like this? Is it a documented
> -- TMK --