Absolute size of 'short'

Earle R. Horton earleh at eleazar.dartmouth.edu
Tue Aug 2 20:54:39 AEST 1988


In article <214 at ISIDAPS5.UUCP> mike at ISIDAPS5.UUCP (Mike Maloney) writes:
>Dear C-Heavies,
>
>Is the size of a (signed or unsigned) short integer guarenteed to
>be two bytes?  I need to manipulate and compare some unsigned ints
>modulo 65536.  It would be clean and convenient to just let the
>machine handle my wrap-around from 0 to 0xffff and verse-vica.

No.  I have seen at least one compiler where sizeof(short) is one
byte.  About the only thing you can count on is that it is no larger
than an int.  You might be safe in 95% of cases in assuming that a
short is shorter than a long, but I don't recommend even this
assumption. 
Earle R. Horton.  H.B. 8000, Dartmouth College, Hanover, NH 03755



More information about the Comp.lang.c mailing list