aboutsummaryrefslogtreecommitdiffstats
path: root/doc/info/chap/integer-types.texinfo
blob: 0684d0b08b28d3ca7fa2a90eff6bdb48e5e2ca18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
@node Integer types
@chapter Integer types


@menu
* Builtin integer types::                     Integer types provided by the compiler.
@end menu



@node Builtin integer types
@section Builtin integer types

@cpindex Integer types
@cpindex Types, integer
@hfindex limits.h
The C programming languages, provides several
integer types. All of these have limited
portability, and are intrinsic (they are
provided by the compiler, not the standard library.)
All constants named in this section of are
made available by including the header file
@file{<limits.h>}.

@table @code
@item char
@tpindex char
The smallest addressable unit of the machine
that can contain a basic character set.
It is either signed or unsigned, depending
on the implementation. It contains @code{CHAR_BIT}
bits. @sc{POSIX} requires that @code{CHAR_BIT == 8},
however the C standard only specifies that
@code{CHAR_BIT >= 8}. The range of this type
is [@code{CHAR_MIN}, @code{CHAR_MAX}].

@item signed char
@tpindex signed char
@iftex
Signed version of @code{char}. It is guaranteed
to have a range of either
[@math{-2}@sup{@code{CHAR_BIT}@math{~-~1}}@math{~+~1},
@math{2}@sup{@code{CHAR_BIT}@math{~-~1}}@math{~-~1}]
or
[@math{-2}@sup{@code{CHAR_BIT}@math{~-~1}},
@math{2}@sup{@code{CHAR_BIT}@math{~-~1}}@math{~-~1}].
The exact range is [@code{SCHAR_MIN}, @code{SCHAR_MAX}].
@end iftex
@ifnottex
Signed version of @code{char}. It is
guaranteed to have a range of at least either
[-2^(@code{CHAR_BIT} - 1) + 1, 2^(@code{CHAR_BIT} - 1) - 1] or
[-2^(@code{CHAR_BIT} - 1), 2^(@code{CHAR_BIT} - 1) - 1].
The exact range is [@code{SCHAR_MIN}, @code{SCHAR_MAX}].
@end ifnottex

@item unsigned char
@tpindex unsigned char
@iftex
Unsigned version of @code{char}. It is guaranteed
to have a range of exactly
[0, @math{2}@sup{@code{CHAR_BIT}}@math{~-~1}],
or equivalently [0, @code{UCHAR_MAX}].
@end iftex
@ifnottex
Unsigned version of @code{char}. It is guaranteed
to have a range of exactly
[0, 2^@code{CHAR_BIT} -1],
or equivalently [0, @code{UCHAR_MAX}].
@end ifnottex

@item short int
@itemx short
@itemx signed short int
@itemx signed short
@tpindex short int
@tpindex signed short int
Signed integer type of at least 16 bits. Its range is
guaranteed contain at least [@math{-32767}, @math{32767}].
The exact range [@code{SHORT_MIN}, @code{SHORT_MAX}].

@itemx unsigned short int
@itemx unsigned short
@tpindex unsigned short int
Unsigned integer type of at least 16 bits. Its range is
guaranteed contain at least [0, @math{65535}].
The exact range [0, @code{USHORT_MAX}].

@item signed int
@itemx int
@tpindex int
@tpindex signed int
Signed integer type of at least 16 bits. Its range is
guaranteed contain at least [@math{-32767}, @math{32767}].
The exact range [@code{INT_MIN}, @code{INT_MAX}].

@item unsigned int
@tpindex unsigned int
Unsigned integer type of at least 16 bits. Its range is
guaranteed contain at least [0, @math{65535}].
The exact range [0, @code{UINT_MAX}].

@item signed
@tpindex signed
Alias for @code{signed int} which is used when the
valid value range is the least guaranteed range. Thus
The range may exceed [@math{-32767}, @math{32767}],
but values outside that range [[@math{-32767},
@math{32767}]] should not be used.

@item unsigned
@tpindex unsigned
Alias for @code{unsigned int} which is used when the
valid value range is the least guaranteed range. Thus
The range may exceed [0, @math{65535}], but values
outside that range [[0, @math{65535}]] should not be used.

@item long int
@itemx long
@itemx signed long int
@itemx signed long
@tpindex signed long int
@tpindex long int
Signed integer type of at least 32 bits. Its range is
guaranteed contain at least [@math{-2147483647},
@math{2147483647}]. The exact range [@code{LONG_MIN},
@code{LONG_MAX}].

@item unsigned long int
@itemx unsigned long
@tpindex unsigned long int
Unsigned integer type of at least 32 bits. Its range is
guaranteed contain at least [0, @math{4294967295}].
The exact range [0, @code{ULONG_MAX}].

@item long long int
@itemx long long
@itemx signed long long int
@itemx signed long long
@tpindex long long int
@tpindex signed long long int
Signed integer type of at least 64 bits. Its range is
guaranteed contain at least [@math{-9223372036854775807},
@math{9223372036854775807}]. This type was added in C99.
The exact range [@code{LLONG_MIN}, @code{LLONG_MAX}].

@item unsigned long long int
@itemx unsigned long long
@tpindex unsigned long long int
Unsigned integer type of at least 64 bits. Its range is
guaranteed contain at least [0, @math{18446744073709551615}].
This type was added in C99. The exact range [0,
@code{ULLONG_MAX}].
@end table