6.1.1 Conversion Specifications

Each conversion specification in the format string is introduced by the % character, after which the following information appears in sequence:

  • Zero or more flags (in any order), that modify the meaning of the conversion specification, as described in Section 6.1.2, “Flag Specifiers”.

  • An optional minimum field width. If the converted value has fewer bytes than the field width, the value is padded with spaces on the left, by default, or on the right, if the left-adjustment flag (-) is specified. The field width can also be specified as an asterisk (*), in which case the field width is set dynamically, based on the value of an additional argument of type int.

  • An optional precision specifier that indicates the following:

    • The minimum number of digits to appear for the d, i, o, u, x, and X conversions— the field is padded with leading zeroes—the number of digits to appear after the radix character for the e, E, and f conversions.

    • The maximum number of significant digits for the g and G conversions.

    • Or the maximum number of bytes to be printed from a string by the s conversion.

    The precision specifier takes the form of a period (.), followed by either an asterisk (*), as described in Section 6.1.3, “Width and Precision Specifiers”, or a decimal digit string.

  • An optional sequence of size prefixes that indicate the size of the corresponding argument. Size prefixes are not required in D, but are provided for compatibility with the C printf() function.

  • A conversion specifier that indicates the type of conversion to be applied to the argument.

The C printf() function also supports conversion specifications of the form %n$, where n is a decimal integer. Note that the DTrace printf function does not support this type of conversion specification.