beautypg.com

Printf conversion characters – Zilog ZUSBOPTS User Manual

Page 460

background image

Standard Functions

UM017105-0511

432

Zilog Developer Studio II – ZNEO™
User Manual

printf Conversion Characters

space

If the first character of a signed conversion is not a sign, a space is added before
the result. If the space and + flags both appear, the space flag is ignored

#

The result is to be converted to an ''alternate form''. For c, d, i, s, and u conver-
sions, 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
always contains a decimal point, even if no digits follow the point (normally, a
decimal point appears in the result of these conversions only if a digit follows it).
For g and G conversions, trailing zeros are not removed from the result, as they
normally are.

d,i,o,u,x,X

The int argument is converted to signed decimal (d or i), unsigned octal (o),
unsigned decimal (u), or unsigned hexadecimal notation (x or X); 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 converted can be represented in fewer digits, it is expanded with
leading zeros. The default precision is 1. The result of converting a zero
value with a precision of zero is no characters.

f

The double argument is converted to decimal notation in the style [-
]ddd.ddd, where the number of digits after the decimal point is equal to the
precision specification. If the precision is missing, it is taken as 6; if the pre-
cision is explicitly zero, no decimal point appears. If a decimal point
appears, at least one digit appears before it. The value is rounded to the
appropriate number of digits.

e,E

The double argument is converted in the style [-]d.ddde+dd, where there is
one digit before the decimal point 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 decimal point appears. The value is rounded to the
appropriate number of digits. The E conversion character produces a num-
ber with E instead of e introducing the exponent. The exponent always con-
tains at least two digits. However, if the magnitude to be converted is
greater than or equal to lE+100, additional exponent digits are written as
necessary.

g,G

The double argument is converted in style f or e (or in style E in the case of
a G conversion character), with the precision specifying the number of sig-
nificant 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 the precision. Trailing zeros are removed from the result; a
decimal point appears only if it is followed by a digit.

c

The int argument is converted to an unsigned char, and the resulting char-
acter is written.

This manual is related to the following products: