home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / bit / listserv / sasl / 5034 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  1.4 KB

  1. Path: sparky!uunet!utcsri!torn!nott!dgbt!netfs!ub!zaphod.mps.ohio-state.edu!darwin.sura.net!paladin.american.edu!auvm!UVVM.BITNET!KLASSEN
  2. From: KLASSEN@UVVM.BITNET (Melvin Klassen)
  3. Newsgroups: bit.listserv.sas-l
  4. Subject: Re: proc FORMAT: oops on numeric values
  5. Message-ID: <SAS-L%92111212311833@VM.UCS.UALBERTA.CA>
  6. Date: 12 Nov 92 19:11:11 GMT
  7. Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. Reply-To: Melvin Klassen <KLASSEN@UVVM.BITNET>
  9. Lines: 21
  10. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  11.  
  12. On Thu, 12 Nov 1992 13:07:00 EST, Ron Fehd <rjf2@PHPDLS1.EM.CDC.GOV> wrote:
  13. >
  14. > I need some help understanding what is happening with the FORMAT
  15. > that I am using to show percents from proc FREQ.
  16. > ...
  17. >  do SAS_N = 98.999 to  99.001 by 0.001,
  18. >             99.999 to 100.001 by 0.001 ;
  19. >    SAS_Frmt = SAS_N;
  20.  
  21. Once again, the hidden dangers of using finite-precision base-two arithmetic
  22. on a digital computer!  Since the value '0.0001' can **not** be stored without
  23. "round-off", your numeric results differ from the predicted, algebraic, results.
  24. (If you ask the computer to compute the sum of 1000 occurrences of '0.001',
  25. the computer will **not** report a value of '1.0'.  Try it!)
  26.  
  27. I got the results you expect when I tried:
  28.  
  29.    do N_SAS = 98999. to  99001. by 0001. ,
  30.               99999. to 100001. by 0001. ;
  31.       SAS_N = N_SAS / 1000.0;  /* Localize the round-off error. */
  32.    SAS_Frmt = SAS_N;
  33.