[NTLUG:Discuss] OT C question

Greg Edwards greg at nas-inet.com
Sat Feb 18 21:53:30 CST 2006


Tom Hayden wrote:
> O.K. To make this really messy. The ANSI C specification says a SHORT 
> int can be no longer than 16 bits. A LONG int must be at least 32 bits. 
> A "STANDARD" int must be at least as long as a SHORT int and no longer 
> than a LONG int. Thus, the length of an int is not truly defined. It is 
> permissible to write a C compiler with a SHORT int of 16 bits, a LONG 
> int of 32 bits and a STANDARD int of 24 bits!! Even worse, on a 64 bit 
> machine, you could have a LONG int of 64 bits and a STANDARD int anyhere 
> from 16 bits to 64 bits, including something truly odd like a STANDARD 
> int 43 bits long!!!! Admittedly, neither of these scenarios makes much 
> sense, but the specification does allow them.
> 
> Eric Schnoebelen wrote:
> 

I thought that 16 bits was the min for a standard int even if a short is 8 
bits?  I know that a standard int can be the same as a long int.  A 
standard int should always be able to support a min range from -32768 to 
+32767.  To know the limits on your system, if you need to go outside of 
-32768 to +32767, you should compare to MAXINT/MININT.


-- 
Greg Edwards
Galactic Outlaw - The Ultimate Cyber Space Adventure
http://GalacticOutlaw.com




More information about the Discuss mailing list