devtoolsforme
Integer Type Ranges
Reference exact-width integer ranges plus stdint.h limit macros and stddef.h size and pointer-difference types.
Exact-width types
stdint.h
Use these when the storage width must match a register, packet field, flash layout, or file format exactly.
At least N bits
stdint.h
These give you the smallest available type that still guarantees at least the requested bit width.
Fastest at least N bits
stdint.h
These trade exact width for the fastest integer type that still provides at least the requested number of bits.
Sizes and pointer deltas
stddef.h + stdint.h limits
Reach for these when you need object sizes, pointer subtraction results, or pointer-sized integer round-trips.
Exact-width ranges
Portable values for the exact-width integer typedefs commonly used in firmware, protocols, and packed binary formats.
| Type | Header | Bits | Min | Max | Limit macros | Hex span |
|---|---|---|---|---|---|---|
| uint8_t | stdint.h | 8 | 0 | 255 | UINT8_MAX | 0x00 - 0xFF |
| int8_t | stdint.h | 8 | -128 | 127 | INT8_MIN / INT8_MAX | 0x80 - 0x7F |
| uint16_t | stdint.h | 16 | 0 | 65,535 | UINT16_MAX | 0x0000 - 0xFFFF |
| int16_t | stdint.h | 16 | -32,768 | 32,767 | INT16_MIN / INT16_MAX | 0x8000 - 0x7FFF |
| uint32_t | stdint.h | 32 | 0 | 4,294,967,295 | UINT32_MAX | 0x00000000 - 0xFFFFFFFF |
| int32_t | stdint.h | 32 | -2,147,483,648 | 2,147,483,647 | INT32_MIN / INT32_MAX | 0x80000000 - 0x7FFFFFFF |
| uint64_t | stdint.h | 64 | 0 | 18,446,744,073,709,551,615 | UINT64_MAX | 0x0000000000000000 - 0xFFFFFFFFFFFFFFFF |
| int64_t | stdint.h | 64 | -9,223,372,036,854,775,808 | 9,223,372,036,854,775,807 | INT64_MIN / INT64_MAX | 0x8000000000000000 - 0x7FFFFFFFFFFFFFFF |
Related standard limits
Useful typedefs and macros from stdint.h and stddef.h when exact-width integers are not the best fit.
| Type or family | Declared in | Limit macros | Guaranteed range | When to use it |
|---|---|---|---|---|
| int_leastN_t / uint_leastN_t | stdint.h | INT_LEASTN_MIN / INT_LEASTN_MAX / UINT_LEASTN_MAX | At least N bits | Smallest implementation type that meets the width guarantee. |
| int_fastN_t / uint_fastN_t | stdint.h | INT_FASTN_MIN / INT_FASTN_MAX / UINT_FASTN_MAX | At least N bits | Fastest implementation type that still meets the width guarantee. |
| intmax_t / uintmax_t | stdint.h | INTMAX_MIN / INTMAX_MAX / UINTMAX_MAX | Implementation-defined widest integer type | Good for generic parsing, formatting, and arithmetic across mixed integer widths. |
| intptr_t / uintptr_t | stdint.h | INTPTR_MIN / INTPTR_MAX / UINTPTR_MAX | Optional pointer-sized integer range | Optional typedefs for safely round-tripping a pointer value through an integer. |
| size_t | typedef in stddef.h, SIZE_MAX in stdint.h | SIZE_MAX | 0 .. SIZE_MAX | Unsigned type returned by sizeof and commonly used for buffer, array, and object sizes. |
| ptrdiff_t | typedef in stddef.h, limits in stdint.h | PTRDIFF_MIN / PTRDIFF_MAX | PTRDIFF_MIN .. PTRDIFF_MAX | Signed type produced by subtracting two pointers into the same array object. |