Fixed width integer types (since C99)
From cppreference.com
Contents |
[edit] Types
Defined in header
<stdint.h> |
|
int8_t int16_t int32_t int64_t
|
signed integer type with width of exactly 8, 16, 32 and 64 bits respectively with no padding bits and using 2's complement for negative values (provided only if the implementation directly supports the type) |
int_fast8_t int_fast16_t int_fast32_t int_fast64_t
|
fastest signed integer type with width of at least 8, 16, 32 and 64 bits respectively |
int_least8_t int_least16_t int_least32_t int_least64_t
|
smallest signed integer type with width of at least 8, 16, 32 and 64 bits respectively |
intmax_t
|
maximum width integer type |
intptr_t
|
integer type capable of holding a pointer |
uint8_t uint16_t uint32_t uint64_t
|
unsigned integer type with width of exactly 8, 16, 32 and 64 bits respectively (provided only if the implementation directly supports the type) |
uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
|
fastest unsigned integer type with width of at least 8, 16, 32 and 64 bits respectively |
uint_least8_t uint_least16_t uint_least32_t uint_least64_t
|
smallest unsigned integer type with width of at least 8, 16, 32 and 64 bits respectively |
uintmax_t
|
maximum width unsigned integer type |
uintptr_t
|
unsigned integer type capable of holding a pointer |
[edit] Macro constants
Defined in header
<stdint.h> |
|
Signed integers : minimum value |
|
INT8_MININT16_MININT32_MININT64_MIN |
minimum value of an object of type int8_t, int16_t, int32_t, int64_t (macro constant) |
INT_FAST8_MININT_FAST16_MININT_FAST32_MININT_FAST64_MIN |
minimum value of an object of type int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t (macro constant) |
INT_LEAST8_MININT_LEAST16_MININT_LEAST32_MININT_LEAST64_MIN |
minimum value of an object of type int_least8_t, int_least16_t, int_least32_t, int_least64_t (macro constant) |
INTPTR_MIN |
minimum value of an object of type intptr_t (macro constant) |
INTMAX_MIN |
minimum value of an object of type intmax_t (macro constant) |
Signed integers : maximum value |
|
INT8_MAXINT16_MAXINT32_MAXINT64_MAX |
maximum value of an object of type int8_t, int16_t, int32_t, int64_t (macro constant) |
INT_FAST8_MAXINT_FAST16_MAXINT_FAST32_MAXINT_FAST64_MAX |
maximum value of an object of type int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t (macro constant) |
INT_LEAST8_MAXINT_LEAST16_MAXINT_LEAST32_MAXINT_LEAST64_MAX |
maximum value of an object of type int_least8_t, int_least16_t, int_least32_t, int_least64_t (macro constant) |
INTPTR_MAX |
maximum value of an object of type intptr_t (macro constant) |
INTMAX_MAX |
maximum value of an object of type intmax_t (macro constant) |
Unsigned integers : maximum value |
|
UINT8_MAXUINT16_MAXUINT32_MAXUINT64_MAX |
maximum value of an object of type uint8_t, uint16_t, uint32_t, uint64_t (macro constant) |
UINT_FAST8_MAXUINT_FAST16_MAXUINT_FAST32_MAXUINT_FAST64_MAX |
maximum value of an object of type uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t (macro constant) |
UINT_LEAST8_MAXUINT_LEAST16_MAXUINT_LEAST32_MAXUINT_LEAST64_MAX |
maximum value of an object of type uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t (macro constant) |
UINTPTR_MAX |
maximum value of an object of type uintptr_t (macro constant) |
UINTMAX_MAX |
maximum value of an object of type uintmax_t (macro constant) |
[edit] Function macros for minimum-width integer constants
INT8_CINT16_CINT32_CINT64_C |
expands to an integer constant expression having the value specified by its argument and the type int_least8_t, int_least16_t, int_least32_t, int_least64_t respectively (function macro) |
INTMAX_C |
expands to an integer constant expression having the value specified by its argument and the type intmax_t (function macro) |
UINT8_CUINT16_CUINT32_CUINT64_C |
expands to an integer constant expression having the value specified by its argument and the type uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t respectively (function macro) |
UINTMAX_C |
expands to an integer constant expression having the value specified by its argument and the type uintmax_t (function macro) |
#include <stdint.h> UINT64_C(0x123) // might expand to 0x123ULL or 0x123UL
[edit] Format macro constants
This section is incomplete Reason: will look better as a table |
Defined in header
<inttypes.h> |
|
Format constants for the fprintf family of functions |
|
PRId8PRId16PRId32PRId64PRIdLEAST8PRIdLEAST16PRIdLEAST32PRIdLEAST64PRIdFAST8PRIdFAST16PRIdFAST32PRIdFAST64PRIdMAXPRIdPTR |
format conversion specifier to output a signed decimal integer value of type int8_t, int16_t, int32_t, int64_t, int_least8_t, int_least16_t, int_least32_t, int_least64_t, int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t, intmax_t, intptr_t respectively, equivalent to %d for int (macro constant) |
PRIi8PRIi16PRIi32PRIi64PRIiLEAST8PRIiLEAST16PRIiLEAST32PRIiLEAST64PRIiFAST8PRIiFAST16PRIiFAST32PRIiFAST64PRIiMAXPRIiPTR |
format conversion specifier to output a signed decimal integer value of type int8_t, int16_t, int32_t, int64_t, int_least8_t, int_least16_t, int_least32_t, int_least64_t, int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t, intmax_t, intptr_t respectively, equivalent to %i for int (macro constant) |
PRIu8PRIu16PRIu32PRIu64PRIuLEAST8PRIuLEAST16PRIuLEAST32PRIuLEAST64PRIuFAST8PRIuFAST16PRIuFAST32PRIuFAST64PRIuMAXPRIuPTR |
format conversion specifier to output an unsigned decimal integer value of type uint8_t, uint16_t, uint32_t, uint64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, uintmax_t, uintptr_t respectively, equivalent to %u for unsigned int (macro constant) |
PRIo8PRIo16PRIo32PRIo64PRIoLEAST8PRIoLEAST16PRIoLEAST32PRIoLEAST64PRIoFAST8PRIoFAST16PRIoFAST32PRIoFAST64PRIoMAXPRIoPTR |
format conversion specifier to output an unsigned octal integer value of type uint8_t, uint16_t, uint32_t, uint64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, uintmax_t, uintptr_t respectively, equivalent to %o for unsigned int (macro constant) |
PRIx8PRIx16PRIx32PRIx64PRIxLEAST8PRIxLEAST16PRIxLEAST32PRIxLEAST64PRIxFAST8PRIxFAST16PRIxFAST32PRIxFAST64PRIxMAXPRIxPTR |
format conversion specifier to output an unsigned hexadecimal integer value of type uint8_t, uint16_t, uint32_t, uint64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, uintmax_t, uintptr_t respectively, equivalent to %x for unsigned int (macro constant) |
PRIX8PRIX16PRIX32PRIX64PRIXLEAST8PRIXLEAST16PRIXLEAST32PRIXLEAST64PRIXFAST8PRIXFAST16PRIXFAST32PRIXFAST64PRIXMAXPRIXPTR |
format conversion specifier to output an unsigned uppercase hexadecimal integer value of type uint8_t, uint16_t, uint32_t, uint64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, uintmax_t, uintptr_t respectively, equivalent to %X for unsigned int (macro constant) |
Format constants for the fscanf family of functions |
|
SCNd8SCNd16SCNd32SCNd64SCNdLEAST8SCNdLEAST16SCNdLEAST32SCNdLEAST64SCNdFAST8SCNdFAST16SCNdFAST32SCNdFAST64SCNdMAXSCNdPTR |
format conversion specifier to input a signed decimal integer value of type int8_t, int16_t, int32_t, int64_t, int_least8_t, int_least16_t, int_least32_t, int_least64_t, int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t, intmax_t, intptr_t respectively, equivalent to %d for int (macro constant) |
SCNi8SCNi16SCNi32SCNi64SCNiLEAST8SCNiLEAST16SCNiLEAST32SCNiLEAST64SCNiFAST8SCNiFAST16SCNiFAST32SCNiFAST64SCNiMAXSCNiPTR |
format conversion specifier to input a signed decimal/octal/hexadecimal integer value of type int8_t, int16_t, int32_t, int64_t, int_least8_t, int_least16_t, int_least32_t, int_least64_t, int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t, intmax_t, intptr_t respectively, equivalent to %i for int (macro constant) |
SCNu8SCNu16SCNu32SCNu64SCNuLEAST8SCNuLEAST16SCNuLEAST32SCNuLEAST64SCNuFAST8SCNuFAST16SCNuFAST32SCNuFAST64SCNuMAXSCNuPTR |
format conversion specifier to input an unsigned decimal integer value of type uint8_t, uint16_t, uint32_t, uint64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, uintmax_t, uintptr_t respectively, equivalent to %u for unsigned int (macro constant) |
SCNo8SCNo16SCNo32SCNo64SCNoLEAST8SCNoLEAST16SCNoLEAST32SCNoLEAST64SCNoFAST8SCNoFAST16SCNoFAST32SCNoFAST64SCNoMAXSCNoPTR |
format conversion specifier to input an unsigned octal integer value of type uint8_t, uint16_t, uint32_t, uint64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, uintmax_t, uintptr_t respectively, equivalent to %o for unsigned int (macro constant) |
SCNx8SCNx16SCNx32SCNx64SCNxLEAST8SCNxLEAST16SCNxLEAST32SCNxLEAST64SCNxFAST8SCNxFAST16SCNxFAST32SCNxFAST64SCNxMAXSCNxPTR |
format conversion specifier to input an unsigned hexadecimal integer value of type uint8_t, uint16_t, uint32_t, uint64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, uintmax_t, uintptr_t respectively, equivalent to %x for unsigned int (macro constant) |
SCNX8SCNX16SCNX32SCNX64SCNXLEAST8SCNXLEAST16SCNXLEAST32SCNXLEAST64SCNXFAST8SCNXFAST16SCNXFAST32SCNXFAST64SCNXMAXSCNXPTR |
format conversion specifier to input an unsigned uppercase hexadecimal integer value of type uint8_t, uint16_t, uint32_t, uint64_t, uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t, uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t, uintmax_t, uintptr_t respectively, equivalent to %X for unsigned int (macro constant) |
[edit] Example
Run this code
Possible output:
8 ld -9223372036854775808 +9223372036854775807 +7