Mail Archives: djgpp/1997/08/22/15:36:06
In article <33FA5146 DOT 797547D8 AT alcyone DOT com>, Erik Max Francis
<max AT alcyone DOT com> wrote:
> Alicia Carla Longstreet wrote:
>
> > Depending on the platform ints can be anywhere from 16 bits on up. The
> > C Standard only requires that it be able to hold numbers from -32768 to
> > 32767 (signed int) or 0 to 65535 (unsigned int). Your use of int to hold
> > 86,400 is not portable and may not even work on your current platform,
> > this would be true even if you used unsigned int.
> >
> > long long is also not standard (I only know of 1 platform/OS that
> > supports this, which is why I suspect that your ints won't work on your
> > platform).
>
> Yes. Short answer: short is guaranteed to be at least 16 bits; long is
> guaranteed to be at least 32. int is guaranteed to be no shorter than a
> short (e.g., at least 16 bits).
>
> If it doesn't much matter what the variable holds, then use int. If space
> is critical, then use short (if you want a _really_ small integer type,
> you might consider using char, but there may be some unexpected pitfalls).
> If it must hold at least 32 bits, then use long.
The last one is not quite correct:
If it must hold at least 17 bits, then use long (because int is not
guaranteed to hold 17 bits). If it must hold 32 bits, long is still ok. If
it must hold 33 bits or more, there is no type that is guaranteed to work.
-- For email responses, please remove the last emm from my address.
-- For spams, please send them to whereever DOT you DOT want AT but DOT not DOT here
- Raw text -