6.7.2 Print Format Macros for Signed Integers

Placeholder macros that can be used with the printf family of functions when printing signed integer values.

Attention: The format macros for 64-bit quantities are not supported when using 8-bit AVR, Baseline, or non-enhanced Mid-range PIC devices with MPLAB XC8.

Include

<inttypes.h>

Remarks

The macros in following table expand to character string literals representing conversion specifier characters that can be used with the printf family of functions when printing signed integer values.

Macro NameDescription
PRId8Decimal placeholder string for a signed 8-bit integer type (int8_t).
PRId16Decimal placeholder string for a signed 16-bit integer type (int16_t).
PRId32Decimal placeholder string for a signed 32-bit integer type (int32_t).
PRId64Decimal placeholder string for a signed 64-bit integer type (int64_t), where supported (see Attention note).
PRIi8Integer placeholder string for a signed 8-bit integer type (int8_t).
PRIi16Integer placeholder string for a signed 16-bit integer type (int16_t).
PRIi32Integer placeholder string for a signed 32-bit integer type (int32_t).
PRIi64Integer placeholder string for a signed 64-bit integer type (int64_t), where supported (see Attention note).
PRIdFAST8Decimal placeholder string for the fastest signed integer type with a width of at least 8 bits (int_fast8_t).
PRIdFAST16Decimal placeholder string for the fastest signed integer type with a width of at least 16 bits (int_fast16_t).
PRIdFAST32Decimal placeholder string for the fastest signed integer type with a width of at least 32 bits (int_fast32_t).
PRIdFAST64Decimal placeholder string for the fastest signed integer type with a width of at least 64 bits (int_fast64_t), where supported (see Attention note).
PRIiFAST8Integer placeholder string for the fastest signed integer type with a width of at least 8 bits (int_fast8_t).
PRIiFAST16Integer placeholder string for the fastest signed integer type with a width of at least 16 bits (int_fast16_t).
PRIiFAST32Integer placeholder string for the fastest signed integer type with a width of at least 32 bits (int_fast32_t).
PRIiFAST64Integer placeholder string for the fastest signed integer type with a width of at least 64 bits (int_fast64_t), where supported (see Attention note).
PRIdLEAST8Decimal placeholder string for a signed integer type with a width of at least 8 bits (int_least8_t).
PRIdLEAST16Decimal placeholder string for a signed integer type with a width of at least 16 bits (int_least16_t).
PRIdLEAST32Decimal placeholder string for a signed integer type with a width of at least 32 bits (int_least32_t).
PRIdLEAST64Decimal placeholder string for a signed integer type with a width of at least 64 bits (int_least64_t), where supported (see Attention note).
PRIiLEAST8Integer placeholder string for a signed integer type with a width of at least 8 bits (int_least8_t).
PRIiLEAST16Integer placeholder string for a signed integer type with a width of at least 16 bits (int_least16_t).
PRIiLEAST32Integer placeholder string for a signed integer type with a width of at least 32 bits (int_least32_t).
PRIiLEAST64Integer placeholder string for a signed integer type with a width of at least 64 bits (int_least64_t), where supported (see Attention note).
PRIdMAXDecimal placeholder string for a signed integer type with maximum width (intmax_t).
PRIiMAXInteger placeholder string for a signed integer type with maximum width (intmax_t).
PRIdPTRDecimal placeholder string for the intptr_t type.
PRIiPTRInteger placeholder string for the intptr_t type.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

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

int8_t s8 = 23;
int_least32_t l32 = -324;

int main(void)
{
  printf("s8 value: %" PRId8 "\n", s8);
  printf("l32 value: %" PRIiLEAST32 "\n", l32);
}