dt

devtoolsforme

Fast browser-side utilities

Back to tools
Embedded

devtoolsforme

Integer Type Ranges

Reference exact-width integer ranges plus stdint.h limit macros and stddef.h size and pointer-difference types.

Use stdint.h when you need fixed-width integer typedefs and portable limit macros, then use stddef.h for object sizes and pointer differences. Exact-width typedefs are optional in the C standard, but when a platform provides them their limits are fixed and portable.

Exact-width types

stdint.h

int8_t, uint16_t, int32_t, uint64_t

Use these when the storage width must match a register, packet field, flash layout, or file format exactly.

At least N bits

stdint.h

int_least8_t, uint_least32_t

These give you the smallest available type that still guarantees at least the requested bit width.

Fastest at least N bits

stdint.h

int_fast8_t, uint_fast16_t

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

size_t, ptrdiff_t, intptr_t, uintptr_t

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.

TypeHeaderBitsMinMaxLimit macrosHex span
uint8_tstdint.h80255UINT8_MAX0x00 - 0xFF
int8_tstdint.h8-128127INT8_MIN / INT8_MAX0x80 - 0x7F
uint16_tstdint.h16065,535UINT16_MAX0x0000 - 0xFFFF
int16_tstdint.h16-32,76832,767INT16_MIN / INT16_MAX0x8000 - 0x7FFF
uint32_tstdint.h3204,294,967,295UINT32_MAX0x00000000 - 0xFFFFFFFF
int32_tstdint.h32-2,147,483,6482,147,483,647INT32_MIN / INT32_MAX0x80000000 - 0x7FFFFFFF
uint64_tstdint.h64018,446,744,073,709,551,615UINT64_MAX0x0000000000000000 - 0xFFFFFFFFFFFFFFFF
int64_tstdint.h64-9,223,372,036,854,775,8089,223,372,036,854,775,807INT64_MIN / INT64_MAX0x8000000000000000 - 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 familyDeclared inLimit macrosGuaranteed rangeWhen to use it
int_leastN_t / uint_leastN_tstdint.hINT_LEASTN_MIN / INT_LEASTN_MAX / UINT_LEASTN_MAXAt least N bitsSmallest implementation type that meets the width guarantee.
int_fastN_t / uint_fastN_tstdint.hINT_FASTN_MIN / INT_FASTN_MAX / UINT_FASTN_MAXAt least N bitsFastest implementation type that still meets the width guarantee.
intmax_t / uintmax_tstdint.hINTMAX_MIN / INTMAX_MAX / UINTMAX_MAXImplementation-defined widest integer typeGood for generic parsing, formatting, and arithmetic across mixed integer widths.
intptr_t / uintptr_tstdint.hINTPTR_MIN / INTPTR_MAX / UINTPTR_MAXOptional pointer-sized integer rangeOptional typedefs for safely round-tripping a pointer value through an integer.
size_ttypedef in stddef.h, SIZE_MAX in stdint.hSIZE_MAX0 .. SIZE_MAXUnsigned type returned by sizeof and commonly used for buffer, array, and object sizes.
ptrdiff_ttypedef in stddef.h, limits in stdint.hPTRDIFF_MIN / PTRDIFF_MAXPTRDIFF_MIN .. PTRDIFF_MAXSigned type produced by subtracting two pointers into the same array object.