Defines integer types with specific properties.
The
stdint.h header file defines several types of integer based on variations of the compiler's built-in integer types (
unsigned int,
int,
long int, and so on). Unlike the general properties of the compiler's integer types, these type definitions have specific properties. The type names describe the integer's properties. Type names beginning with
int represent types for signed integers in two's-complement form. Type names beginning with
uint are unsigned integer types.
These integer types are:
- Exact-width integers - These types occupy the exact number of bits specified by their type names. The names of these types take the form intN_t and uintN_t, where N represents the exact number of bits in values of these types. The names of these types are int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, and uint64_t.
- Minimum-width integers - These types occupy at least the number of bits specified by their type names. For each of these integer types, the library guarantees that there is no integer type that has a smaller size. The names of these types take the form int_leastN_t and uint_least_N_t. The N specifies that the integer type has N or more bits and that no smaller integer type holds this number of bits.
The names of these types are
int_least8_t,
uint_least8_t,
int_least16_t,
uint_least16_t,
int_least32_t,
uint_least32_t,
int_least64_t, and
uint_least64_t.
- Fastest integers - These integer types represent the optimal size for the target processor. These types are closest to the native numeric types that the target processor uses. The names of these types take the form int_fastN_t and uint_fast_N_t. The N specifies that the integer type has N or more bits and that no smaller integer type holds this number of bits.
The names of these types are
int_fast8_t,
uint_fast8_t,
int_fast16_t,
uint_fast16_t,
int_fast32_t,
uint_fast32_t,
int_fast64_t, and
uint_fast64_t.
- Pointer-width integers - These types are large enough to hold a pointer value. Converting a void pointer value to this integer type then converting this integer value to a pointer again will result in the original pointer value.
The names of these types are
intptr_t,
uintptr_t.
- Greatest-width integers - These integer types are large enough to contain any integer value. Converting any integer value to this integer type then converting this integer value to the original integer type will result in the original integer value. Values of type intmax_t can contain any signed integer value. Values of type uintmax_t can contain any unsigned integer.