L-VIS User Manual
296
LOYTEC
Version 6.2
LOYTEC electronics GmbH
example, it will not work to use a %d specifier for a text control or a %s specifier for a
numeric control.
The format string is composed of zero or more directives: ordinary characters (not
%
),
which are copied unchanged to the output stream; and conversion specifications, each of
which results in fetching zero or more subsequent arguments. Each conversion specification
is introduced by the character
%
, and ends with a
conversion specifier
. In between there
may be (in this order) zero or more
flags
, an optional minimum
field width
, an optional
precision
and an optional
length modifier
. For some numeric conversions a radix character
(‘decimal point’) or thousands’ grouping character is used. The actual character used
depends on the implementation. Non-localized number controls always use ‘.’ as radix
character, and do not use grouping.
15.7.1.1 Flags
The character % is followed by zero or more of the following flags:
#
The value should be converted to an ‘‘alternate form’’. For
o
conversions, the first
character of the output string is made zero (by prefixing a 0 if it was not zero already). For
x
and
X
conversions, a nonzero result has the string ‘0x’ (or ‘0X’ for
X
conversions)
prepended to it. For
a
,
A
,
e
,
E
,
f
,
F
,
g
, and
G
conversions, the result will always contain a
decimal point, even if no digits follow it (normally, a decimal point appears in the results of
those conversions only if a digit follows). For
g
and
G
conversions, trailing zeros are not
removed from the result as they would otherwise be. For other conversions, the result is
undefined.
0
The value should be zero padded. For
d
,
i
,
o
,
u
,
x
,
X
,
a
,
A
,
e
,
E
,
f
,
F
,
g
, and
G
conversions, the converted value is padded on the left with zeros rather than blanks. If the
0
and
−
flags both appear, the
0
flag is ignored. If a precision is given with a numeric
conversion (
d
,
i
,
o
,
u
,
x
, and
X
), the
0
flag is ignored. For other conversions, the behavior is
undefined.
−
The converted value is to be left adjusted on the field boundary. (The default is right
justification.) Except for
n
conversions, the converted value is padded on the right with
blanks, rather than on the left with blanks or zeros. A
−
overrides a
0
if both are given.
’ ’
(a space) A blank should be left before a positive number (or empty string) produced by
a signed conversion.
+
A sign (+ or -) always be placed before a number produced by a signed conversion. By
default a sign is used only for negative numbers. A
+
overrides a space if both are used.
15.7.1.2 Field Width
An optional decimal digit string (with nonzero first digit) specifying a minimum field
width. If the converted value has fewer characters than the field width, it will be padded
with spaces on the left (or right, if the left-adjustment flag has been given). A negative field
width is taken as a ‘-’ flag followed by a positive field width. In no case does a non-existent
or small field width cause truncation of a field; if the result of a conversion is wider than
the field width, the field is expanded to contain the conversion result.
15.7.1.3 Precision
An optional precision, in the form of a period (‘.’) followed by an optional decimal digit
string. If the precision is given as just ‘.’, or the precision is negative, the precision is taken
to be zero. This gives the minimum number of digits to appear for
d
,
i
,
o
,
u
,
x
, and
X
conversions, the number of digits to appear after the radix character for
a
,
A
,
e
,
E
,
f
, and
F
conversions, the maximum number of significant digits for
g
and
G
conversions, or the
maximum number of characters to be printed from a string for
s
and
S
conversions.