Purpose: | Display a formatted string using the C Printf format |
Format: | PRINTF "format string" args ... |
Usage:
The arguments following the format string will be inserted in the output string according to the format type in the format string. The arguments can be variable names, variable functions, or literal strings; i.e.:
PRINTF "%s %d %x" %var1 999 %hexvar
The format type syntax is:
%[flags][width][.precision][length]type
flags |
description |
- |
Left-justify within the given field width; Right justification is the default (see width sub-specifier). |
+ |
Prefix the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a - sign. |
0 |
Prefix the number with zeroes (0) instead of spaces when padding is specified (see width sub-specifier). |
width |
description |
number |
Minimum number of characters to be printed. If the value to be printed is less than this number, the result is padded with spaces. |
* |
The width is not specified in the format string, but as an additional integer argument preceding the argument to be formatted. |
.precision |
description |
.number |
For integer specifiers (d, i, o, u, x, X): precision is the minimum number of digits to be written. If the value to be written is less than precision, the result is padded with leading zeros. For f and g specifiers: The maximum number of significant digits to be printed. |
.* |
The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted. |
Type |
Output |
d or i |
Signed decimal integer |
u |
Unsigned decimal integer |
x |
Unsigned hexadecimal integer |
X |
Unsigned uppercase hexadecimal integer |
f or g |
Decimal floating point |
c |
Character |
s |
String |
% |
A % followed by another % will write a single % |
If you prefix a type with an L, PRINTF will insert commas as thousands separators. For example:
PRINTF "%Ld" 123456789
will output:
123,456,789