There are 10 types in C for representing integers.
The range of values that each can represent varies between implementations.
The range of values that each can represent varies between implementations.
There is a guaranteed minimum range that each every C implementation should provide for each type.
| name | guaranteed | typical | <limits.h>
| min | max | min | max | min | max
| char (*) | -127 | 127 | -128 | 127 | SCHAR_MIN | SCHAR_MAX
| unsigned char | 0 | 255 | 0 | 255 | UCHAR_MAX
| short | -32767 | 32767 | -32768 | 32767 | SHRT_MIN | SHRT_MAX
| unsigned short | 0 | 65535 | 0 | 65535 | USHRT_MAX
| int | -32767 | 32767 | -2147483648 | 2147483647 | INT_MIN | INT_MAX
| unsigned int | 0 | 65535 | 0 | 4294967295 | UINT_MAX
| long | -2147483647 | 2147483647 | -2147483647 | 2147483647 | LONG_MIN | LONG_MAX
| unsigned long | 0 | 4294967295 | 0 | 4294967295 | ULLONG_MAX
| long long | -9223372036854775807 | 9223372036854775807 | -9223372036854775807 | 9223372036854775807 | LLONG_MIN | LLONG_MAX
| unsigned long long | 0 | 184467444073709551615 | 0 | 184467444073709551615 | ULLONG_MAX
| | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
(*) On some machines the type char is equivalent to unsigned char.
For most purposes use int.
Integers appearing the text of a program are, by default, of type int.