```Date: Mon, 21 Nov 2011 12:31:44 -0500 Reply-To: bbser 2009 Sender: "SAS(r) Discussion" From: bbser 2009 Subject: Re: the largest integer, numeric variable of length 3 Comments: To: Bolotin Yevgeniy In-Reply-To: <01384B2401936142AF5F65E3D12402780B775B0B@EX3VS1.nyced.org> Content-Type: text/plain; charset="us-ascii" Thank you, Bolotin, for correcting my error. I need coffee now! Regards, Max (Maaxx) -----Original Message----- From: Bolotin Yevgeniy [mailto:YBolotin@schools.nyc.gov] Sent: November-21-11 12:23 PM To: bbser 2009; SAS-L@LISTSERV.UGA.EDU Subject: RE: the largest integer, numeric variable of length 3 The reason it's 8192 and not 4096 is because it looks like the sign is rolled into the exponent (so your real exponent is actually 10 bits?) Also, 8192 is not the biggest number that you can store in a 3., but merely the biggest number you can store exactly. The exponent stores the power of 2 that you need, not the value of that power of 2, and so the number of distinct values you can technically store is up to 0.1111111111 x (11 ^ 11111111111) in binary = (whatever) x (2^2^11) in decimal, and not 2^11 as you said. but of course only the most significant 12 bits of the mantissa will be used, which is why 8193 in 3. format is still 8192 -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of bbser 2009 Sent: Monday, November 21, 2011 11:49 AM To: SAS-L@LISTSERV.UGA.EDU Subject: the largest integer, numeric variable of length 3 Greetings All! Out of curiosity, I was trying to figure out why the largest integer stored in a numeric variable of length 3 on Windows is 8192. First, here is a good tutorial about how SAS stores decimal numbers. http://kipirvine.com/asm/workbook/floating_tut.htm Back to the topic, since the length is 3, then 1 bit for the sign, 11 for exponent, 12 for mantissa. Thus the largest binary is 1.111111111111x(2^11) (12 successive 1's right behind the dot) or 111111111111.1 (12 successive 1's right before the dot). Therefore the largest binary integer should be the one represented by 12 successive 1's, which is 4095 given by this code: 11436 data _null_; 11437 do i=0 to 11; 11438 sum+2**i; 11439 end; 11440 put sum; 11441 run; 4095 NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds What am I missing? Thank you very much! Regards, Max (Maaxx) ```

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