Integer Types
There
are five signed integer types: signed
char
, short
int
(or short),
int
, long
int
(or long), and long long
int
(*) (or
long long
(*)). For each
of these types there is a corresponding
unsigned integer type with the same
storage size. The unsigned type is designated by the prefix
unsigned in the type specifier, as in
unsigned int.
The types char
, signed char, and
unsigned char
are formally different. Depending on the
compiler settings, however, char is equivalent
either to signed char or to unsigned
char. The prefix signed has no meaning
for the types short, int,
long, and long
long
(*), however, since they are
always considered to be signed. Thus short and
signed short specify the same type.
The storage size of the integer types is not defined; however, their
width is ranked in the following order: char <=
short <= int <=
long <= long
long
(*). Furthermore, the size
of type short is at least 2 bytes,
long at least 4 bytes, and long
long at least 8 bytes. Their value ranges for a given
implementation are found in the header file
limits.h
.
ANSI C99 also introduces the type
_Bool
to represent Boolean
values. The Boolean value true is represented by
1 and false by
0. If the header file
stdbool.h
has been included, then
bool can be used as a synonym for
_Bool and the macros true and
false for the integer constants
1 and 0. Table 1-3 shows the standard integer types together with
some typical value ranges.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access