1.1.8 printf() style format string

Certain commands use printf() style format strings to specify how to format values. For example the set print double-format and set print float-format commands specify how to format floating-point values. It works in a similar way to the ANSI C standard library function printf().

Format string syntax

The commands specify the format using a string. If there are no % characters in the string, the message is written out and any arguments are ignored. The % symbol is used to indicate the start of an argument conversion specification.

The syntax of the format string is:

%[flag...][fieldwidth][precision]format

where:

flag

An optional conversion modification flag.

"-"

result is left-justified

"#"

result uses a conversion-dependent alternate form

"+"

result includes a sign

" "

result includes a leading space for positive values

"0"

result is zero-padded

","

result includes locale-specific grouping separator

"("

result encloses negative numbers in parentheses.

fieldwidth

An optional minimum field width specified in decimal.

precision

An optional precision specified in decimal, with a preceding . (period character) to identify it.

format

The possible conversion specifier characters are:

%

A literal % character.

a, A, e, E, f, g or G

Results in a decimal number formatted using scientific notation or floating point notation. The capital letter forms use a capital E in scientific notation rather than an e.

d or u

Results in a decimal integer. d indicates a signed integer. u indicates an unsigned integer.

h or H

Results in a Hexadecimal character in lower or upper case.

x or X

Results in an unsigned Hexadecimal character in lower or upper case.

o

Results in an octal integer.

c or C

Results in a Unicode character in lower or upper case.

s

Results in a string.

b or B

Results in a string containing either "true" or "false" in lower or upper case.

n

Results in a platform-specific line separator.

t or T

Prefix for date and time conversion specifier characters. For example:

"%ta %tb %td %tT" results in "Sun Jul 20 16:17:00"

Non-ConfidentialPDF file icon PDF versionARM DUI0452Z
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.