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 the next section.

  • An optional minimum field width. If the converted value has fewer bytes than the field width, the value will be 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 that indicates 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 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. The size prefixes are not required in D, and 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. DTrace's printf does not support this type of conversion specification.