HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)

p
printf(1) printf(1)
digit string. A null digit string is treated as a zero.
conversion characters
A conversion character indicates the type of conversion to be applied:
d,i,
o,u,
x,X
The integer argument is printed a signed decimal (
d or i), unsigned octal
(
o), unsigned decimal (u
), or unsigned hexadecimal notation (x and X). The
x conversion uses the numbers and letters
0123456789abcdef, and the
X conversion uses the numbers and letters
0123456789ABCDEF. The
precision component of the argument specifies the minimum number of
digits to appear. If the value being converted can be represented in fewer
digits than the specified minimum, it is expanded with leading zeroes. The
default precision is 1. The result of converting a zero value with a precision
of 0 is no characters.
f The floating-point number argument is printed in decimal notation in the
style [-]ddd rddd, where the number of digits after the radix character,
r,
is equal to the precision specification. If the precision is omitted from the
argument, six digits are output; if the precision is explicitly 0, no radix
appears.
e,E The floating-point-number argument is printed in the style [
-]drddde±dd,
where 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 0, no radix character appears. The
E conversion character produces a number with E introducing the
exponent instead of e. The exponent always contains at least two digits.
However, if the value to be printed requires an exponent greater than two
digits, additional exponent digits are printed as necessary.
g,G The floating-point-number argument is printed in style
f or e (or int style
E in the case of a G conversion character), with the precision specifying the
number of significant digits. The style used depends on the value con-
verted; style e is used only if the exponent resulting from the conversion is
less than -h or greater than or equal to the precision. Trailing zeros are
remove from the result. A radix character appears only if it is followed by a
digit.
c The first character of the argument is printed.
s The argument is taken to be a string, and characters from the string are
printed until the end of the string or the number of characters indicated by
the precision specification of the argument is reached. If the precision is
omitted from the argument, it is interpreted as infinite and all characters
up to the end of the string are printed.
% Print a % character; no argument is converted.
b Similar to the s conversion specifier, except that the string can contain
backslash-escape sequences which are then converted to the characters
they represent.
In no case does a nonexistent or insufficient field width cause truncation of a field; if the
result of a conversion is wider than the field width, the field is simply expanded to con-
tain the conversion result.
EXTERNAL INFLUENCES
Environment Variables
LC_CTYPE determines the interpretation of arg as single and/or multi-byte characters.
LC_MESSAGES determines the language in which messages are displayed.
If LC_CTYPE or LC_MESSAGES is not specified in the environment or is set to the empty string, the
value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is
set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.
If any internationalization variable contains an invalid setting, printf behaves as if all internationalization
variables are set to "C". See environ(5).
HP-UX 11i Version 1: September 2005 2 Hewlett-Packard Company Section 1783