Uses of "short" ?

Bill Crews bc at cyb-eng.UUCP
Wed Sep 11 04:45:29 AEST 1985


> What are the reasons for using the type short in C ?  On
> machines that have a different size for "int" and "short"
> the reason seems obvious, space.  However, I would appreciate any thoughts
> on there usefulness there also.  Specifically, I am interested
> in its use on machines where sizeof (int) = sizeof (short).
> 
> Thx

The percentage of machines in the universe that are either 16-bit or 32-bit
machines is very highgh.  Therefore, one can get a great degree (but certainly
not total) compatibility of communicated information by refraining from
declaring ints in structures, but instead declaring either shorts or longs.
All compilers for such machines of which I am aware implement short as 16 bits
and long as 32 bits, although the definition of int may go either way.  So, for
my data files and communications protocols, this is what I do.  If I run into
a 36-bit or 48-bit machine, I may have some work to do.

By the way, the uint16-type stuff mentioned lately on the net can help here
also.
-- 
  /  \    Bill Crews
 ( bc )   Cyb Systems, Inc
  \__/    Austin, Texas

[ gatech | ihnp4 | nbires | seismo | ucbvax ] ! ut-sally ! cyb-eng ! bc



More information about the Comp.lang.c mailing list