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:
“I was not at all shocked with this execution at the time. John died seemingly without much pain. He was effectually hanged, the rope having fixed upon his neck very firmly, and he was allowed to hang near three quarters of an hour; so that any attempt to recover him would have been in vain. I comforted myself in thinking that by giving up the scheme I had avoided much anxiety and uneasiness.”
—James Boswell (17401795)
“Newly stumbling to and fro
All they find, outside the fold,
Is a wretched width of cold.”
—Philip Larkin (19221986)
“He types his laboured columnweary drudge!
Senile fudge and solemn:
Spare, editor, to condemn
These dry leaves of his autumn.”
—Robertson Davies (b. 1913)