printf.3s (2010 09)

p
printf(3S) printf(3S)
The a, e, f, and
g conversions will print inf for infinity and nan for both quiet and signaling NaN
values.
The
A, E, F, and
G conversions will print INF for infinity and NAN for both quiet and signaling NaN
values.
For
a and A conversions (on Itanium(R)-based systems), the value is correctly rounded to a hexadecimal
floating point number with the given precision.
The
e, E, f,
F, g, and G conversions on Itanium(R)-based systems round according to the specification in
ISO/IEC C99: if the number of significant decimal digits is at most 36, then the result is correctly
rounded.
Characters generated by
printf() and fprintf() are printed as if
putc() had been called (see
putc (3S)).
For Itanium(R)-based systems if the optional decimal floating point feature is installed and enabled, the
behavior of the
f, F,
e, E, g, and G specifiers for decimal floating point numbers is the same as for
dou-
ble.
Application Usage
To use the
_INCLUDE__STDC_A1_SOURCE
functionality, the
_INCLUDE__STDC_A1_SOURCE
flag
must be passed as a compiler option or defined as a macro in source files.
After
printf() or fprintf() is applied to a stream, the stream becomes byte-oriented (see orienta-
tion (5)).
EXTERNAL INFLUENCES
Environment Variables
The
LC_CTYPE category affects the following features:
Plain characters within format strings are interpreted as single byte and/or multibyte characters.
Field width is given in terms of bytes. As characters are placed on the output stream, they are
interpreted as single byte or multibyte characters and the field width is decremented by the length
of the character.
Precision is given in terms of bytes. As characters are placed on the output stream, they are inter-
preted as single byte or multibyte characters and the precision is decremented by the length of the
character.
The return value is given in terms of bytes. As characters are placed on the output stream, they are
interpreted as single byte or multibyte characters and the byte count that makes up the return
value is incremented by the length of the character.
The
LC_NUMERIC category determines the radix character used to print floating-point numbers, and the
thousands grouping characters if the grouping flag
is on.
International Code Set Support
Single byte character code sets are supported. Multibyte character code sets are also supported as
described in the
LC_CTYPE category above.
RETURN VALUE
Each function returns the number of bytes transmitted (excluding the
\0 null character in the case of
sprintf()) or a negative value if an output error was encountered.
By default,
snprintf() returns a negative value if maxsize is smaller than the number of characters
formatted. In the UNIX 2003 standards environment (see standards (5)) it returns the the number of
bytes that would have been written to buffer s, excluding the terminating null byte, if maxsize had been
sufficiently large.
ERRORS
printf(), and fprintf() fail if either the stream is unbuffered or stream s buffer needed to be
flushed causing an underlying write() call to be invoked (see write (2)), and:
[EAGAIN] The
O_NONBLOCK flag is set for the file descriptor underlying stream and the process
would be delayed in the write operation.
[EBADF] The file descriptor underlying stream is not a valid file descriptor open for writing.
HP-UX 11i Version 3: September 2010 5 Hewlett-Packard Company 5