home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / bit / listserv / sasl / 4138 < prev    next >
Encoding:
Text File  |  1992-09-10  |  4.5 KB  |  80 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!spool.mu.edu!darwin.sura.net!paladin.american.edu!auvm!CUNYVM.BITNET!FXTBB
  3. Message-ID: <SAS-L%92091017120031@UGA.CC.UGA.EDU>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Thu, 10 Sep 1992 16:54:19 EDT
  6. Reply-To:     Philip Tejera <FXTBB@CUNYVM.BITNET>
  7. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. From:         Philip Tejera <FXTBB@CUNYVM.BITNET>
  9. Subject:      Previous postings about length
  10. Lines: 68
  11.  
  12. Thanks to Ben Conner for pointing out that the archives at Marist go back
  13. further (to 86) than do the ones I checked. So here is Christian's answer
  14. from 1988. Interesting how this has come up again after 4 years.
  15.  
  16. >>> Item number 1910, dated 88/07/25 11:48:42 -- ALL
  17. Date:         Mon, 25 Jul 88 11:48:42 SET
  18. Reply-To:     "Christian J. Reichetzeder" <REICHETZ@AWIIMC11>
  19. Sender:       "SAS(r) Discussion" <SAS-L@MARIST>
  20. From:         "Christian J. Reichetzeder" <REICHETZ@AWIIMC11>
  21. Subject:      Re: A little Depth about Length
  22. In-Reply-To:  Message of Fri, 22 Jul 88 14:21:32 EDT from <RESBB@CUNYVM>
  23.  
  24. >Before we get too bored with repeating what the manuals say about Length and
  25. >the precision of variables, let's think a minute :-)  ! As far as I know,
  26. >IBM mainframes do floating point math on single (4-byte), double (8-byte),
  27. >or extended (16-byte) precision variables. SAS doesn't seem to use the
  28. >extended precision, so I'll stick to single and double precision. Fine.
  29. >But wait..what about those other possible lengths 2,3,5,6,7 that we are only
  30. >supposed to use for integers up to various sizes? HOW CAN THEY BE STORED AS
  31. >FLOATING POINT? Or are they? Actually, the manual only talks about NUMERIC
  32. >type variables. It says that SAS uses the (IBM) floating point instructions
  33. >provided by the hardware (p. 228 Basics) for calculations, but I can't find
  34. >anything about how it stores the values. Does it even store Length 4 or 8
  35. >values as floating point, or does it use some other IBM or its own way of
  36. >storing them? I don't think it truely uses IBM integer formats, because
  37. >one can, for example, divide length 2 variables by 2 and get the right answer
  38. >if the values are small enough. One can even divide such values by 3 and get
  39. >the wrong answer ! (But close). Does anyone out there want to dive into this?
  40.  
  41. Sorry for repeating the whole text but I think it's needed.
  42. Yes, IBM /370 has short(4), long(8)  and extended (16) floating point. I don't
  43. know if  SAS internally  uses extended floating  point for  some calculations,
  44. maybe.
  45. To answer the question "how does SAS the LENGTH-trick" let's look:
  46. a) at  the SAS  Basics (Vers 5),  page 157 (dealing  with LENGTH  and "Largest
  47.    Integer Represented Exactly" (I take only 2-4, the table is up to 8).
  48.            Length           LIRE
  49.              2               255
  50.              3            65,535
  51.              4        16,777,215 .....
  52.    Now if I'd use an INTEGER  (!) 2 bytes would hold -32768..+32767. Obviously
  53.    SAS does NOT and NEVER use integer format.
  54. b) at the representation of a /370 floating point(long form):
  55.            +-+--------------+------/-------+
  56.            |S|Characteristic|   Fraction   |
  57.            +-+--------------|------/-------+
  58.     Bits:  0 1              8             63
  59.     "S" is the sign-bit. Characteristic  is the exponent in Excess-64 notation
  60.     (meaning  exponent -64..+63  are mapped  to  0..127 resp.).  The point  is
  61.     assumed immediately  to the  left of fraction.  Furthermore the  number is
  62.     "normalized"  so that  the  leftmost  hex digit  is  non-zero to  maintain
  63.     maximum precision  (i.e. at least one  of bits 8-11  is ^= 0 except  for a
  64.     "true zero" - where also the Sign and Charac. are zero).
  65. Therefore you end with
  66.           number = (-1*(S=1))*Fraction*(16**(Characteristic-64))
  67. Note that  the difference between short,  long and extended floating  point is
  68. mainly precision,  not magnitude. When  storing a  number SAS simply  cuts the
  69. string  to length  LENGTH  -  losing some  precision  but  nothing else.  When
  70. fetching the numbers they're (I assume) simply padded on the right.
  71. Now  we also  can see  the  correspondence between  LENGTH and  LIRE. You  can
  72. exactly represent a (LENGTH-1)-Byte integer.
  73. Deep enough?
  74. Christian
  75. P.S.: the biggest number with LENGTH 8  is approx. 7.237E+75, at LENGTH 2 it's
  76.       7.209E+75, you  don't really lose  much :-).  And the smallest  value is
  77.       something like 5.3976E-79 for all formats.
  78. P.P.S.: oh yes,  it uses  "it's  own way"   for storing  missing values:  Zero
  79.         Fraction and non-zero Sign/Characteristic.
  80.