```Date: Thu, 7 Mar 2002 17:29:10 +0100 Reply-To: Jim Groeneveld Sender: "SAS(r) Discussion" From: Jim Groeneveld Subject: Re: Numeric representation Comments: To: kviel Content-Type: text/plain; charset="iso-8859-1" Dear Kevin, 1) you are right: dec255 = hexFF = 16*16 = 2**8, so it occupies 2 bytes of 8 bits each 2) base 16 is identical to hexadecimal, with digits 0-9 and A-F, totally 16 digits with values 0-15 A bit can have 2 states only indeed: 0 or 1 and 255 is the largest one-byte integer. But integers may be built of more bytes, 2, 4, 8. The largest integer values may be calculated as: 2 (bit states) ** { 8 (bits) * } - 1 For 2 bytes this is 256**2 - 1 = 65535. However, bit patterns may be interpreted differently according to numerical type. E.g. 2 byte integers may range from -32768 to +32767. In C this is the usual integer type in which: dec0 = bin0000 0000 0000 0000 = hex00 00 dec32767 = bin0111 1111 1111 1111 = hex7F FF dec-32768 = bin 1000 0000 0000 0000 = hex80 00 dec-1 = bin 1111 1111 1111 1111 = hexFF FF Likewise other integers (with 4 and 8 bytes) may be interpreted in different ways, depending on their type in a programming language. So different type and value integers may actually have identical bit patterns. These are not floating point values. Floating point values are bit patterns where a (major) part of the bits is interpreted as integer values, one bit determines the mantissa and the remaining bits are interpreted as some integer exponent, something like the exponent of 10. This makes value representations like 123E456 or -789,123E-4, and thus all fractional values possible. How many bits are interpreted to represent one of the parts of a bitt pattern may be hardware and software dependent. I did not quite understand you remaining questions, but I trust they may be answered sufficiently by the above explanation. HTH. Regards - Jim. -- Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statistician, P.O. Box 1 fax. +31 412 407 080 senior data manager 5350 AA BERGHEM IMRO TRAMARKO: a CRO J.Groeneveld@ITGroups.com the Netherlands in clinical research My computer beeps when it complains; I complain when it beeps Notice of confidentiality: this e-mail may contain confidential information intended for the addressed recipient only. If you have received this e-mail in error please delete this e-mail and please notify the sender so that proper delivery can be arranged. > -----Original Message----- > From: kviel [SMTP:kviel@GMCF.ORG] > Sent: Thursday, March 07, 2002 4:32 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Numeric representation > > Greetings, > > I have been trying to understand storage (representation) of > numeric > values, in particular floating point representation. I have read TS-654 > "Numeric precision 101". I also have TS-230, but have only started it. I > have some likely remedial questions, so I apologize if I ask what might be > obvious. > > 1) F in hexadecimal is 15 in decimal. So FF should be 15*16**1 + > 15*16**0 = 255. > Which is 1111 1111 in binary (base 2?) = > 1*2**7 + 1*2**6 + 1*2**5 + 1*2**4 + 1*2**3 + 1*2**2 + 1*2**1 + > 1*2**0 > > How many bytes does this require? (One? F = 1111 in binary-4 > bits) > > 2) On the mainframe, the base is 16. So using two bytes, I have one > full byte to store > the mantissa. However, since the largest integer is 256 (TS-654, > page 2), > I infer that it is not stored as: > > x1*16**7 + x2*16**6 + x3*16**5 + x4*16**4 + x5*16**3 + x6*16**2 > + > x7*16**1 + x8*16**0 > where x1-x8: 0-F. > > This is consistent with my limited knowledge of hardware: a bit > can > have only 2 states, > not 16. What does it mean, then, that the mainframe is BASE 16? > > 3) It seems that if I follow these formulas, then I am underestimate > the reported largest > integer by -1 [See 1) above 255 not 256]. Should I have started > with an exponent of 1? > > On MVS, I will try to represent the storage of the largest integer > possible > for 2 bytes: > > 1- Convert decimal 256 to hexadecimal: 100 (256=1*16**2 + 0*16**1 + > 0*16**0) > 2- 0.100*16**3 > ^^^^^^ TS-654 page 7: 512 decimal = .200*16**3 > Does this denote BASE 16 and a shift of the decimal place > by convention? > (Otherwise I would have interpreted it as > (16**3)/10=409.6) > > 3- No fraction > 4- Stored exponent in hexidecimal 43 > Hexadecimal 43 = 67 decimal = 0100 0011 binary (01000003 is a > misprint?) > 5-43 100 (SEEEEEEE MMMMMMMM) > ^^^ It seems to me that this is *more* than two bytes. > > However, if operation under some of the above (mis)conceptions, this *is* > two bytes: > > 1- Convert decimal 255 to hexadecimal: 11 (255=15*16**1 + 15*16**0) > 2- 0.11*16**2 > 3- No fraction > 4- Stored exponent in hexidecimal 42 > Hexadecimal 43 = 66 decimal = 0100 0010 binary > 5-4211 > > > I have not devoted adequate time to this question, so I hope that it is > clear. I appreciate any clarifications. > > *** TS-654: http://ftp.sas.com/techsup/download/technote/ts654.html > > Regards, > > Kevin > > Kevin Viel > Georgia Medical Care Foundation > 57 Executive Park South, NE > suite 200 > Atlanta, GA 30329-2224 ```

Back to: Top of message | Previous page | Main SAS-L page