◐ Shell
clean mode source ↗

Fixed width integer types (since C99)

Types

For each of the following typedef names marked (optional), an implementation defines it if and only if the implementation provides a corresponding type.

Defined in header <stdint.h>

int8_tint16_tint32_tint64_tintN_t

(optional)(optional)(optional)(optional)(optional)

signed integer type with width of exactly N (typically 8, 16, 32 or 64) bits and no padding bits
(typedef) [edit]

int_fast8_tint_fast16_tint_fast32_tint_fast64_tint_fastN_t

(optional)

fastest signed integer type with width of at least N (typically 8, 16, 32 or 64) bits
(typedef) [edit]

int_least8_tint_least16_tint_least32_tint_least64_tint_leastN_t

(optional)

smallest signed integer type with width of at least N (typically 8, 16, 32 or 64) bits
(if intN_t is defined, int_leastN_t designates the same type)
(typedef) [edit]

intmax_t

maximum-width signed integer type other than a bit-precise integer type(since C23)
(typedef) [edit]

intptr_t

(optional)

signed integer type other than a bit-precise integer type(since C23) capable of holding a pointer to void
(typedef) [edit]

uint8_tuint16_tuint32_tuint64_tuintN_t

(optional)(optional)(optional)(optional)(optional)

unsigned integer type with width of exactly N (typically 8, 16, 32 or 64) bits and no padding bits
(typedef) [edit]

uint_fast8_tuint_fast16_tuint_fast32_tuint_fast64_tuint_fastN_t

(optional)

fastest unsigned integer type with width of at least N (typically 8, 16, 32 or 64) bits
(typedef) [edit]

uint_least8_tuint_least16_tuint_least32_tuint_least64_tuint_leastN_t

(optional)

smallest unsigned integer type with width of at least N (typically 8, 16, 32 or 64) bits
(if uintN_t is defined, uint_leastN_t designates the same type)
(typedef) [edit]

uintmax_t

maximum-width unsigned integer type other than a bit-precise integer type(since C23)
(typedef) [edit]

uintptr_t

(optional)

unsigned integer type other than a bit-precise integer type(since C23) capable of holding a pointer to void
(typedef) [edit]

Macro constants

For each of the following macros marked (conditionally present), an implementation defines it if and only if the implementation defines the corresponding typedef name.

Defined in header <stdint.h>

Signed integers : bit width

INTN_WIDTH

(C23)(conditionally present)

bit width of intN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INT_FASTN_WIDTH

(C23)(conditionally present)

bit width of int_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INT_LEASTN_WIDTH

(C23)(conditionally present)

bit width of int_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INTMAX_WIDTH

(C23)

bit width of intmax_t
(macro constant) [edit]

INTPTR_WIDTH

(C23)(conditionally present)

bit width of intptr_t
(macro constant) [edit]
Signed integers : minimum value

INTN_MIN

(conditionally present)

minimum value of intN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INT_FASTN_MIN

(conditionally present)

minimum value of int_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INT_LEASTN_MIN

(conditionally present)

minimum value of int_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INTMAX_MIN

minimum value of intmax_t
(macro constant) [edit]

INTPTR_MIN

(conditionally present)

minimum value of intptr_t
(macro constant) [edit]
Signed integers : maximum value

INTN_MAX

(conditionally present)

maximum value of intN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INT_FASTN_MAX

(conditionally present)

maximum value of int_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INT_LEASTN_MAX

(conditionally present)

maximum value of int_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

INTMAX_MAX

maximum value of intmax_t
(macro constant) [edit]

INTPTR_MAX

(conditionally present)

maximum value of intptr_t
(macro constant) [edit]
Unsigned integers : bit width

UINTN_WIDTH

(C23)(conditionally present)

bit width of uintN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

UINT_FASTN_WIDTH

(C23)(conditionally present)

bit width of uint_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

UINT_LEASTN_WIDTH

(C23)(conditionally present)

bit width of uint_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

UINTMAX_WIDTH

(C23)

bit width of uintmax_t
(macro constant) [edit]

UINTPTR_WIDTH

(C23)(conditionally present)

bit width of uintptr_t
(macro constant) [edit]
Unsigned integers : maximum value

UINTN_MAX

(conditionally present)

maximum value of uintN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

UINT_FASTN_MAX

(conditionally present)

maximum value of uint_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

UINT_LEASTN_MAX

(conditionally present)

maximum value of uint_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant) [edit]

UINTMAX_MAX

maximum value of uintmax_t
(macro constant) [edit]

UINTPTR_MAX

(conditionally present)

maximum value of uintptr_t
(macro constant) [edit]

Function macros

For each of the following macros marked (conditionally present), an implementation defines it if and only if the implementation defines the corresponding typedef name.

INTN_C

(conditionally present)

expands to an integer constant expression of type int_leastN_t, its value is specified by the argument
(function macro) [edit]
expands to an integer constant expression of type intmax_t, its value is specified by the argument
(function macro) [edit]

UINTN_C

(conditionally present)

expands to an integer constant expression of type uint_leastN_t, its value is specified by the argument
(function macro) [edit]
expands to an integer constant expression of type uintmax_t, its value is specified by the argument
(function macro) [edit]
#include <stdint.h>
UINT64_C(0x123) // might expand to 0x123ULL or 0x123UL

Format macro constants

Format constants for the fprintf family of functions

Each of the PRI macros listed here is defined if and only if the implementation defines the corresponding typedef name.

Equivalent
for int or
unsigned int
Description Macros for data types

[u]intx_t

[u]int_leastx_t

[u]int_fastx_t

[u]intmax_t

[u]intptr_t

d output of a signed decimal integer value PRIdx PRIdLEASTx PRIdFASTx PRIdMAX PRIdPTR
i PRIix PRIiLEASTx PRIiFASTx PRIiMAX PRIiPTR
u output of an unsigned decimal integer value PRIux PRIuLEASTx PRIuFASTx PRIuMAX PRIuPTR
o output of an unsigned octal integer value PRIox PRIoLEASTx PRIoFASTx PRIoMAX PRIoPTR
x output of an unsigned lowercase hexadecimal integer value PRIxx PRIxLEASTx PRIxFASTx PRIxMAX PRIxPTR
X output of an unsigned uppercase hexadecimal integer value PRIXx PRIXLEASTx PRIXFASTx PRIXMAX PRIXPTR

Format constants for the fscanf family of functions

Each of the SCN macros listed in here is defined if and only if the implementation defines the corresponding typedef name and has a suitable fscanf length modifier for the type.

Equivalent
for int or
unsigned int
Description Macros for data types

[u]intx_t

[u]int_leastx_t

[u]int_fastx_t

[u]intmax_t

[u]intptr_t

d input of a signed decimal integer value SCNdx SCNdLEASTx SCNdFASTx SCNdMAX SCNdPTR
i input of a signed integer value (base is determined by the first characters parsed) SCNix SCNiLEASTx SCNiFASTx SCNiMAX SCNiPTR
u input of an unsigned decimal integer value SCNux SCNuLEASTx SCNuFASTx SCNuMAX SCNuPTR
o input of an unsigned octal integer value SCNox SCNoLEASTx SCNoFASTx SCNoMAX SCNoPTR
x input of an unsigned hexadecimal integer value SCNxx SCNxLEASTx SCNxFASTx SCNxMAX SCNxPTR

Example

See also C++ compatibility note regarding spaces before format macros used in this example.

#include <inttypes.h>
#include <stdio.h>

int main(void)
{
    printf("%zu\n", sizeof(int64_t));
    printf("%s\n", PRId64);
    printf("%+" PRId64 "\n", INT64_MIN);
    printf("%+" PRId64 "\n", INT64_MAX);
    
    int64_t n = 7;
    printf("%+" PRId64 "\n", n);
}

Possible output:

8
lld
-9223372036854775808
+9223372036854775807
+7

References

  • C23 standard (ISO/IEC 9899:2024):
  • 7.8.1 Macros for format specifiers (p: TBD)
  • 7.18 Integer types <stdint.h> (p: TBD)
  • C17 standard (ISO/IEC 9899:2018):
  • 7.8.1 Macros for format specifiers (p: 158-159)
  • 7.18 Integer types <stdint.h> (p: 212-216)
  • C11 standard (ISO/IEC 9899:2011):
  • 7.8.1 Macros for format specifiers (p: 217-218)
  • 7.18 Integer types <stdint.h> (p: 289-295)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.8.1 Macros for format specifiers (p: 198-199)
  • 7.18 Integer types <stdint.h> (p: 255-261)

See also