char
is guaranteed to hold only 0 to 127, and can be either unsigned
or signed
char
; you cannot assume one or the other. Avoid char
unless you do not care about sign extension.
unsigned
char
can hold from 0 to 255; it can hold more.
signed
char
can hold from -127 to +127; it can hold more.
short
can hold from -32,767 to 32,767 (signed) or 0 to 65,535 (unsigned).
int
can hold from -32,767 to 32,767 (signed) or 0 to 65,535 (unsigned). Ints cannot be counted on to hold any more than a short. If you need something larger than a short
, use a long
. If a short
is big enough, use int
instead to improve efficiency by taking advantage of a processor's natural word size.
int
by casting it to a short
, because that's all you're guaranteed to get.int
because int
doesn't have a portable representation.long
can hold from -2,147,483,647 to 2,147,483,647 (signed) or 0 to 4,294,967,295 (unsigned).
float
is a IEEE single-precision number and double
is a IEEE double-precision number. This is because the Taligent Application Environment runs only on processors that support the IEEE floating point standard and that support the single- and double-precision types.
limits.h
and float.h
. However, remember that the values of these symbols can change from processor to processor or compiler to compiler, within the limits defined above (for more information, see the ANSI/ISO C specification).
In general, watch your assumptions carefully, and use typedef
s instead of C types. For examples, see "Avoid raw C types with dimensions" on page 66.