long vs. int vs. short guidelines (especially for wizards!!)

Ed Gould ed at unisoft.UUCP
Tue Apr 17 17:00:57 AEST 1984


Actually, there are times that you do want to use int.  On some
machines, int is faster than short, even though you may need only
16 bits.  Int represents the "natural" integer size for the hardware,
but it's only guranteed to be at least 16 bits.

Use int, therefore, when you don't care about the space consumed
and 16 bits is enough (e.g., not in a struct that will be written
to a file).

As an example of where int might be faster than short, consider
a machine with 32-bit registers, but where the 16-bit operations
don't clear the upper bits of the register.  Usually, the compiler
will have to do the manipulation of the upper bits in a separate
instruction.

-- 
Ed Gould
ucbvax!mtxinu!ed



More information about the Comp.unix.wizards mailing list