printf.3s (2010 09)

p
printf(3S) printf(3S)
blank If the first character of a signed conversion is not a sign, a blank is prefixed to the result.
This implies that if the blank and
+ flags both appear, the blank flag is ignored.
# This flag specifies that the value is converted to an "alternate form". For
c, d, i, s, n
,
and
u conversions, the flag has no effect. For
o conversion, it increases the precision to
force the first digit of the result to be a zero. For
x or X conversion, a nonzero result is
prefixed by
0x or 0X.Fora
p conversion, a nonzero result is prefixed by 0x.For
a, A, e,
E, f, F, g, and
G conversions, the result always contains a radix character, even if no
digits follow the radix. (Normally, a radix character appears in the resulting conversions
only if followed by a digit). For
g and G conversions, trailing zeros are not removed from
the result (which they normally are).
0 Leading zeros (following any indication of sign or base) are used to pad to the field width
for all conversion characters. No space padding is performed. If both the
0 and -
appear, the 0 flag is ignored. For
d, i, o, u, p, x, and X
, conversions, if a precision is
specified, the
0 flag is ignored.
The conversion characters and their meanings are:
d,i,o,u
,x,X The integer arg is converted to signed decimal (d and i are identical), unsigned
octal (
o), decimal (u), or hexadecimal notation (
x and X), respectively; the letters
abcdef are used for x conversion and the letters
ABCDEF for X conversion. The
precision specifies the minimum number of digits to appear. If the value being con-
verted can be represented in fewer digits, it is expanded with leading zeros. (For
compatibility with older versions, padding with leading zeros can alternatively be
specified by inserting a zero in front of the field width. This does not imply an octal
value for the field width). The default precision is 1. The result of converting a
zero value with a precision of zero is a null string.
f,F The double arg is converted to decimal notation in the style [-]dddrddd, where r is
the radix character. The number of digits after the radix character is equal to the
precision specification. If the precision is missing, six digits are output. If the pre-
cision is explicitly zero, no radix character appears.
e,E The double arg is converted in the style [-]drddde±
dd, where r is the radix charac-
ter. There is one digit before the radix character and the number of digits after it is
equal to the precision. When the precision is missing, six digits are produced. If
the precision is zero, no radix character appears. The
E format code produces a
number with E instead of e introducing the exponent. The exponent always con-
tains at least two digits.
g,G The double arg is printed in style f, F,ore (or in style
E in the case of a G format
code), with the precision specifying the number of significant digits. The style used
depends on the value converted: style
e is used only if the exponent resulting from
the conversion is less than -4 or greater than or equal to the precision. Trailing
zeros are removed from the fractional part of the result; a radix character appears
only if it is followed by a digit.
a,A For Itanium(R)-based systems only. The double arg is converted in the style
[-]0xhrhhhp±d, where r is the radix character. There is one digit before the radix
character and the number of digits after it is equal to the precision. When the pre-
cision is missing, 13 digits are produced for double, 15 for extended, and 28 for
long double (which is sufficient for an exact representation of the value). If the
precision is 0, no radix character appears. The letters abcdef are used for a
conversion and the letters ABCDEF for A conversion. The A conversion specifier
produces a number with X and P instead of x and p. The exponent always con-
tains at least one digit, and only as many more digits as necessary to represent the
decimal exponent of 2. If the value is zero, the exponent is zero.
For Itanium(R)-based systems if the optional decimal floating point feature is
installed and enabled, then for an
a or A specifier, if an H, D,orDD modifier is
present and the precision is missing, then for a decimal floating type argument
represented with an integral coefficient c and quantum exponent q, where n is the
number of digits in the coefficient c:
If 0 >= q >= -(n+5), use style
f formatting with formatting precision equal to
-q.
HP-UX 11i Version 3: September 2010 3 Hewlett-Packard Company 3