- C language
- C type
- here
Traditional C language integer type
A list of traditional C language integer types. The list is translated and quoted from C data types on Wikipedia.
type | Explanation | Minimum size (bits) | Format specifier |
---|---|---|---|
char | The minimum addressable unit of a machine that can contain the basic character set. It is an integer type. The actual type is either signed or unsigned. | 8 | %c |
signed char | char , but guaranteed to be signed. It can include at least the range [−127, +127]. | 8 | %c (%hhi for numeric output )
|
unsigned char | char , but guaranteed to be unsigned. Includes at least a range of [0, 255]. | 8 | %c (or %hhu for numeric output)
|
short short int signed short signed short int |
Short Signed integer type. It can include at least the range [-32,767, +32,767]. | 16 | %hi or %hd |
unsigned short unsigned short int |
Short Unsigned integer type. Includes at least a range of [0, 65, 535]. | 16 | %hu |
int signed signed int |
Basic signed integer type. It can include at least the range [-32,767, +32,767]. | 16 | %i or %d |
unsigned unsigned int |
Basic unsigned integer type. Includes at least a range of [0, 65, 535]. | 16 | %u |
long long int signed long signed long int |
Long Signed integer type. It can include at least the [-2,147,483,647, +2,147,483,647] range. | 32 | %li or %ld |
unsigned long unsigned long int |
Long Unsigned integer type. It can contain at least the [0,4,294,967,295] range. | 32 | %lu |
long long long long int signed long long signed long long int |
Long Long Signed integer type. It can include at least the [-9,223,372,036,854,775,807, +9,223,372,036,854,775,807] range. C99 Specified after the standard version. |
64 | %lli or %lld |
unsigned long long unsigned long long int |
Long long sign None Integer type. It includes at least the [0, +18,446,744,073,709,551,615] range. C99 Standard specification after version. | 64 | %llu |
Notes on traditional C integer types
Here are some caveats about traditional C integer types.
Char with and without sign depends on the processing system
Signed / unsigned char depends on the processing system. By setting "signed char" and "unsigned char", it is possible to confirm whether the sign is signed or unsigned.
This is confusing, so char is used to represent characters, and uint8_t when expressing html "> int8_t and unsigned 8-bit integer type.
int is not a signed 32-bit integer
Note that the C specification defines only the minimum width for traditional integer types. The minimum width of int is 16bit. It is implemented as a 32-bit integer type in many processing systems, but please note that it is not a 32-bit signed integer type as a C language specification.
When dealing with integer types, it is recommended to use the width-guaranteed integer types introduced in C99.