Fixed Width Integer Types
The C99 standard includes definitions of several new integer types to enhance the portability of programs. The already available basic integer types were deemed insufficient, because their actual sizes are implementation defined and may vary across different systems. The new types are especially useful in embedded environments where hardware supports usually only several types and that support varies from system to system. All new types are defined in inttypes.h
header (cinttypes
header in C++) and also are available at stdint.h
header (cstdint
header in C++). The types can be grouped into the following categories:
- Exact width integer types which are guaranteed to have the same number N of bits across all implementations. Included only if it is available in the implementation.
- Least width integer types which are guaranteed to be the smallest type available in the implementation, that has at least specified number N of bits. Guaranteed to be specified for at least N=8,16,32,64.
- Fastest integer types which are guaranteed to be the fastest integer type available in the implementation, that has at least specified number N of bits. Guaranteed to be specified for at least N=8,16,32,64.
- Pointer integer types which are guaranteed to be able to hold a pointer
- Maximum width integer types which are guaranteed to be the largest integer type in the implementation
The following table summarizes the types and the interface to acquire the implementation details (N refers to the number of bits):
Type category | Signed types | Unsigned types | ||||
---|---|---|---|---|---|---|
Type | Minimum value | Maximum value | Type | Minimum value | Maximum value | |
Exact width | intN_t |
INTN_MIN |
INTN_MAX |
uintN_t |
0 | UINTN_MAX |
Least width | int_leastN_t |
INT_LEASTN_MIN |
INT_LEASTN_MAX |
uint_leastN_t |
0 | UINT_LEASTN_MAX |
Fastest | int_fastN_t |
INT_FASTN_MIN |
INT_FASTN_MAX |
uint_fastN_t |
0 | UINT_FASTN_MAX |
Pointer | intptr_t |
INTPTR_MIN |
INTPTR_MAX |
uintptr_t |
0 | UINTPTR_MAX |
Maximum width | intmax_t |
INTMAX_MIN |
INTMAX_MAX |
uintmax_t |
0 | UINTMAX_MAX |
Read more about this topic: C Data Types
Famous quotes containing the words fixed, width and/or types:
“The word obligation is very seldom in my thoughts, and consequently very seldom is it uttered by my tongue. For I am satisfied that whoever hath the word obligation continually in his mouth hath the love of tyranny steadily fixed in his heart.”
—Sarah Fielding (17101768)
“Newly stumbling to and fro
All they find, outside the fold,
Is a wretched width of cold.”
—Philip Larkin (19221986)
“The rank and file have let their servants become their masters and dictators.... Provision should be made in all union constitutions for the recall of leaders. Big salaries should not be paid. Career hunters should be driven out, as well as leaders who use labor for political ends. These types are menaces to the advancement of labor.”
—Mother Jones (18301930)