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 Name Description
PRId8 Decimal placeholder string for a signed 8-bit integer type (int8_t).
PRId16 Decimal placeholder string for a signed 16-bit integer type (int16_t).
PRId32 Decimal placeholder string for a signed 32-bit integer type (int32_t).
PRId64 Decimal placeholder string for a signed 64-bit integer type (int64_t), where supported (see Attention note).
PRIi8 Integer placeholder string for a signed 8-bit integer type (int8_t).
PRIi16 Integer placeholder string for a signed 16-bit integer type (int16_t).
PRIi32 Integer placeholder string for a signed 32-bit integer type (int32_t).
PRIi64 Integer placeholder string for a signed 64-bit integer type (int64_t), where supported (see Attention note).
PRIdFAST8 Decimal placeholder string for the fastest signed integer type with a width of at least 8 bits (int_fast8_t).
PRIdFAST16 Decimal placeholder string for the fastest signed integer type with a width of at least 16 bits (int_fast16_t).
PRIdFAST32 Decimal placeholder string for the fastest signed integer type with a width of at least 32 bits (int_fast32_t).
PRIdFAST64 Decimal placeholder string for the fastest signed integer type with a width of at least 64 bits (int_fast64_t), where supported (see Attention note).
PRIiFAST8 Integer placeholder string for the fastest signed integer type with a width of at least 8 bits (int_fast8_t).
PRIiFAST16 Integer placeholder string for the fastest signed integer type with a width of at least 16 bits (int_fast16_t).
PRIiFAST32 Integer placeholder string for the fastest signed integer type with a width of at least 32 bits (int_fast32_t).
PRIiFAST64 Integer placeholder string for the fastest signed integer type with a width of at least 64 bits (int_fast64_t), where supported (see Attention note).
PRIdLEAST8 Decimal placeholder string for a signed integer type with a width of at least 8 bits (int_least8_t).
PRIdLEAST16 Decimal placeholder string for a signed integer type with a width of at least 16 bits (int_least16_t).
PRIdLEAST32 Decimal placeholder string for a signed integer type with a width of at least 32 bits (int_least32_t).
PRIdLEAST64 Decimal placeholder string for a signed integer type with a width of at least 64 bits (int_least64_t), where supported (see Attention note).
PRIiLEAST8 Integer placeholder string for a signed integer type with a width of at least 8 bits (int_least8_t).
PRIiLEAST16 Integer placeholder string for a signed integer type with a width of at least 16 bits (int_least16_t).
PRIiLEAST32 Integer placeholder string for a signed integer type with a width of at least 32 bits (int_least32_t).
PRIiLEAST64 Integer placeholder string for a signed integer type with a width of at least 64 bits (int_least64_t), where supported (see Attention note).
PRIdMAX Decimal placeholder string for a signed integer type with maximum width (intmax_t).
PRIiMAX Integer placeholder string for a signed integer type with maximum width (intmax_t).
PRIdPTR Decimal placeholder string for the intptr_t type.
PRIiPTR Integer 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);
}