8 Star 183 Fork 8

Lucifer / Programming-in-D-in-Chinese

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
formattedoutput.html 130.97 KB
一键复制 编辑 原始数据 按行查看 历史
Lucifer 提交于 2014-02-06 17:05 . Programming in D in English
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Formatted Output</title>
</head>
<body>
<h4 style="margin: 1.25em 0.5em 0.5em 8px; padding: 0px; border: 0px; outline: 0px; font-size: 1.5em; vertical-align: baseline; background-color: transparent; font-family: sans-serif; font-weight: bold; color: rgb(0, 0, 51); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Formatted Output</h4>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
This chapter is about features of Phobos&#39;s<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">std.format</code><span class="Apple-converted-space">&nbsp;</span>module,
not about the core features of the D language.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
D&#39;s input and output format specifiers are similar to the ones in the C
language.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Before going further, I would like to summarize the format specifiers and flags
as a reference:</p>
<pre class="mono" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"><b style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">Flags</b> (can be used together)
- flush left
+ print sign
# print in the alternative way
0 print zero-filled
<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">space</i> print space-filled
<b style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">Format Specifiers</b>
s default
b binary
d decimal
o octal
x,X hexadecimal
e,E scientific floating point
f,F dotted floating point
g,G as e or f
a,A hexadecimal floating point
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
We have been using functions like<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">writeln</code><span class="Apple-converted-space">&nbsp;</span>with
multiple parameters as necessary. The parameters would be converted to their
string representations and then sent to the output.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Sometimes this is not sufficient. The output may have to be in a certain format.
Let&#39;s look at the following code that is used to print items of an invoice:</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> items ~= 1.23;
items ~= 45.6;
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">for</span> (<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">int</span> i = 0; i != items.length; ++i) {
writeln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Item &quot;</span>, i + 1, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;: &quot;</span>, items[i]);
}
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
The output:</p>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">Item 1: 1.23
Item 2: 45.6
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Despite the information being correct, it may be required to be printed in a
certain format. For example the dots may have to be lined up and that there must
always be two digits after the dot as in the following output:</p>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">Item 1: 1.23
Item 2: 45.60
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Formatted output is useful in such cases. The output functions that we have been
using so far has counterparts that contain the letter<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">f</code><span class="Apple-converted-space">&nbsp;</span>in
their names:<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">writef()</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">writefln()</code>.
The letter<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">f</code><span class="Apple-converted-space">&nbsp;</span>is
short for<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">formatted</i>.
The first parameter of these functions is a<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">format
string</i>that describes how the other parameters should be printed.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
For example, the format string that would have<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">writefln()</code><span class="Apple-converted-space">&nbsp;</span>produce
the desired output above is the following:</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Item %d:%9.02f&quot;</span>, i + 1, items[i]);
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
The format string contains regular characters that are passed to the output
as-is, as well as special format specifiers that correspond to each parameter
that is to be printed. Format specifiers start with the<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%</code><span class="Apple-converted-space">&nbsp;</span>character
and ends with a<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">format
character</i>. The format string above has two format specifiers:<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%d</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%9.02f</code>.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Every specifier is associated to the following parameters in order. For example,<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%d</code><span class="Apple-converted-space">&nbsp;</span>is
associated with<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">i&nbsp;+&nbsp;1</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%9.02f</code><span class="Apple-converted-space">&nbsp;</span>is
associated with<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">items[i]</code>.
Every specifier specifies the format of the parameter that it corresponds to.
(Format specifiers may have parameter numbers as well. This will be explained
later in the chapter.)</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
All of the other characters of the format string that are not parts of format
specifiers are printed as-is. Such<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">regular</i><span class="Apple-converted-space">&nbsp;</span>characters
of the format specifier above are highlighted as red as in<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">&quot;</code><span class="d_string" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;"><tt style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">Item&nbsp;</tt></span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%d</code><span class="d_string" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;"><tt style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">:</tt></span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%9.02f&quot;</code>.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Format specifiers consist of six parts most of which are optional. The part
named<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">position</i><span class="Apple-converted-space">&nbsp;</span>will
be explained later below. The other five are the following (<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"><b style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">Note:</b><span class="Apple-converted-space">&nbsp;</span>The
spaces between these parts are inserted here to help with readability; they are
not parts of the specifiers.</i>):</p>
<pre class="mono" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">% <i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">flags width precision format_character</code></i></span>
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
The<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%</code><span class="Apple-converted-space">&nbsp;</span>character
at the beginning and the format character at the end are required; the others
are optional.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Because<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%</code><span class="Apple-converted-space">&nbsp;</span>has
a special meaning in format strings, when a<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%</code><span class="Apple-converted-space">&nbsp;</span>needs
to be printed as a regular character, it must be typed as<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%%</code>.</p>
<h5 style="margin: 1.25em 0.5em 0.5em 8px; padding: 0px; border: 0px; outline: 0px; font-size: 1.25em; vertical-align: baseline; background-color: transparent; font-family: sans-serif; font-weight: bold; color: rgb(0, 0, 51); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 20px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
format_character</i></h5>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
b</code>: Integer parameter is printed in the binary system.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
o</code>: Integer parameter is printed in the octal system.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
x</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">X</code>:
Integer parameter is printed in the hexadecimal system; with lowercase letters
for<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">x</code><span class="Apple-converted-space">&nbsp;</span>and
uppercase letters for<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">X</code>.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
d</code>: Integer parameter is printed in decimal system; a negative sign is
also printed if it is a signed type and the value is less than zero.</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Binary : %b&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Octal : %o&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Hexadecimal: %x&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Decimal : %d&quot;</span>, value);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">Binary : 1100
Octal : 14
Hexadecimal: c
Decimal : 12
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
e</code>: Floating point parameter is printed according to the following rules.</p>
<ul style="margin: 0.5em 1em 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
single digit before the dot</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
dot if<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i><span class="Apple-converted-space">&nbsp;</span>is
non-zero</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
digits after the dot, number of which is determined by<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i>(default
precision is 6)</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">e</code><span class="Apple-converted-space">&nbsp;</span>character
(meaning &quot;10 to the power of&quot;)</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">-</code><span class="Apple-converted-space">&nbsp;</span>or<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">+</code><span class="Apple-converted-space">&nbsp;</span>character
depending on whether the exponent is less than or greater than zero</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
the exponent consisting of at least two digits</li>
</ul>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
E</code>: Same as in<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">e</code><span class="Apple-converted-space">&nbsp;</span>with
the exception of the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">E</code><span class="Apple-converted-space">&nbsp;</span>character
at the output instead of<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">e</code>.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
f</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">F</code>:
Floating point parameter is printed in the decimal system; there is at least one
digit before the dot and the default precision is 6.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
g</code>: Same as in<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">f</code><span class="Apple-converted-space">&nbsp;</span>if
the exponent is between -5 and<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i>;
otherwise as in<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">e</code>.<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i><span class="Apple-converted-space">&nbsp;</span>does
not specify the number of digits after the dot, but the significant digits of
the entire value. If there are no significant digits after the dot, then the dot
is not printed. The rightmost zeros after the dot are not printed.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
G</code>: Same as in<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">g</code><span class="Apple-converted-space">&nbsp;</span>with
the exception of<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">E</code><span class="Apple-converted-space">&nbsp;</span>or<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">F</code><span class="Apple-converted-space">&nbsp;</span>at
the output.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
a</code>: Floating point parameter is printed in the hexadecimal floating
format:</p>
<ul style="margin: 0.5em 1em 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
the characters<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">0x</code></li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
single hexadecimal digit</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
dot if<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i><span class="Apple-converted-space">&nbsp;</span>is
non-zero</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
digits after the dot, number of which is determined by<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i>;
if no<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i><span class="Apple-converted-space">&nbsp;</span>is
specified, then as many digits as necessary</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">p</code><span class="Apple-converted-space">&nbsp;</span>character
(meaning &quot;2 to the power of&quot;)</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">-</code><span class="Apple-converted-space">&nbsp;</span>or<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">+</code><span class="Apple-converted-space">&nbsp;</span>character
depending on whether the exponent is less than or greater than zero</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
the exponent consisting of at least one digit (the exponent of the value 0
is 0)</li>
</ul>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
A</code>: Same as in<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">a</code><span class="Apple-converted-space">&nbsp;</span>with
the exception of the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">0X</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">P</code><span class="Apple-converted-space">&nbsp;</span>characters
at the output.</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">double</span> value = 123.456789;
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;with e: %e&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;with f: %f&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;with g: %g&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;with a: %a&quot;</span>, value);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">with e: 1.234568e+02
with f: 123.456789
with g: 123.457
with a: 0x1.edd3c07ee0b0bp+6
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
s</code>: The value is printed in the same way as in non-formatted output,
according to the type of the parameter:</p>
<ul style="margin: 0.5em 1em 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
bool</code><span class="Apple-converted-space">&nbsp;</span>values as<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">true</code><span class="Apple-converted-space">&nbsp;</span>or<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">false</code></li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
integer values same as<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%d</code></li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
floating point values same as<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%g</code></li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
strings in UTF-8 encoding;<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i><span class="Apple-converted-space">&nbsp;</span>determines
the maximum number of bytes to use (remember that in UTF-8 encoding, the
number of bytes is not the same as the number of characters; for example the
string &quot;&quot; has 2 characters, consisting a total of 3 bytes)</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
struct and class objects as the return value of the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">toString()</code>member
functions of their types;<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i><span class="Apple-converted-space">&nbsp;</span>determines
the maximum number of bytes to use</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
arrays as their element values side by side</li>
</ul>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">bool</span> b = <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">true</span>;
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">int</span> i = 365;
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">double</span> d = 9.87;
string s = <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;formatted&quot;</span>;
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">auto</span> o = File(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;test_file&quot;</span>, <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;r&quot;</span>);
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">int</span>[] a = [ 2, 4, 6, 8 ];
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;bool : %s&quot;</span>, b);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;int : %s&quot;</span>, i);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;double: %s&quot;</span>, d);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;string: %s&quot;</span>, s);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;object: %s&quot;</span>, o);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;array : %s&quot;</span>, a);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">bool : true
int : 365
double: 9.87
string: formatted
object: File(55738FA0)
array : [2, 4, 6, 8]
</pre>
<h5 style="margin: 1.25em 0.5em 0.5em 8px; padding: 0px; border: 0px; outline: 0px; font-size: 1.25em; vertical-align: baseline; background-color: transparent; font-family: sans-serif; font-weight: bold; color: rgb(0, 0, 51); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 20px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
width</i></h5>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
This part determines the width of the field that the parameter is printed in. If
the width is specified as the character<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">*</code>,
then the actual width value is read from the next parameter. If width is a
negative value, then the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">-</code><span class="Apple-converted-space">&nbsp;</span>flag
is assumed.</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">int</span> value = 100;
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;In a field of 10 characters:%10s&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;In a field of 5 characters :%5s&quot;</span>, value);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">In a field of 10 characters: 100
In a field of 5 characters : 100
</pre>
<h5 style="margin: 1.25em 0.5em 0.5em 8px; padding: 0px; border: 0px; outline: 0px; font-size: 1.25em; vertical-align: baseline; background-color: transparent; font-family: sans-serif; font-weight: bold; color: rgb(0, 0, 51); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 20px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
precision</i></h5>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Precision is specified after a dot in the format specifier. For floating point
types, it determines the precision of the printed representation of the values.
If the precision is specified as the character<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">*</code>,
then the actual precision is read from the next parameter (that parameter must
be an<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">int</code>).
Negative precision values are ignored.</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">double</span> value = 1234.56789;
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;%.8g&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;%.3g&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;%.8f&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;%.3f&quot;</span>, value);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">1234.5679
1.23e+03
1234.56789000
1234.568
</pre>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">auto</span> number = 0.123456789;
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Number: %.*g&quot;</span>, 4, number);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">Number: 0.1235
</pre>
<h5 style="margin: 1.25em 0.5em 0.5em 8px; padding: 0px; border: 0px; outline: 0px; font-size: 1.25em; vertical-align: baseline; background-color: transparent; font-family: sans-serif; font-weight: bold; color: rgb(0, 0, 51); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 20px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
flags</i></h5>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
More than one flag can be specified.</p>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
-</code>: the value is printed left-aligned in its field; this flag cancels the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">0</code><span class="Apple-converted-space">&nbsp;</span>flag</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">int</span> value = 123;
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Normally right-aligned:|%10d|&quot;</span>, value);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Left-aligned :|%-10d|&quot;</span>, value);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">Normally right-aligned:| 123|
Left-aligned :|123 |
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
+</code>: if the value is positive, it is prepended with the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">+</code><span class="Apple-converted-space">&nbsp;</span>character;
this flag cancels the<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">space</i><span class="Apple-converted-space">&nbsp;</span>flag</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;No effect for negative values : %+d&quot;</span>, -50);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Positive value with the + flag : %+d&quot;</span>, 50);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Positive value without the + flag: %d&quot;</span>, 50);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">No effect for negative values : -50
Positive value with the + flag : +50
Positive value without the + flag: 50
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
#</code>: prints the value in an<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">alternate</i><span class="Apple-converted-space">&nbsp;</span>form
depending on the<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">format_character</i></p>
<ul style="margin: 0.5em 1em 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
o</code>: the first character of the octal value is always printed as 0</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
x</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">X</code>:
if the value is not zero, it is prepended with<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">0x</code><span class="Apple-converted-space">&nbsp;</span>or<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">0X</code></li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
floating points: a dot is printed even if there are no significant digits
after the dot</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
g</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">G</code>:
even the insignificant zero digits after the dot are printed</li>
</ul>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Octal starts with 0 : %#o&quot;</span>, 1000);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Hexadecimal starts with 0x : %#x&quot;</span>, 1000);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Contains dot even when unnecessary: %#g&quot;</span>, 1f);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Rightmost zeros are printed : %#g&quot;</span>, 1.2);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">Octal starts with 0 : 01750
Hexadecimal starts with 0x : 0x3e8
Contains dot even when unnecessary: 1.00000
Rightmost zeros are printed : 1.20000
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
0</code>: the field is padded with zeros (unless the value is<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">nan</code><span class="Apple-converted-space">&nbsp;</span>or<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">infinity</code>);
if<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">precision</i><span class="Apple-converted-space">&nbsp;</span>is
also specified, this flag is ignored</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;In a field of 8 characters: %08d&quot;</span>, 42);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">In a field of 8 characters: 00000042
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
space</i><span class="Apple-converted-space">&nbsp;</span>character: if the value is
positive, a space character is prepended to align the negative and positive
values</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;No effect for negative values: % d&quot;</span>, -34);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Positive value with space : % d&quot;</span>, 56);
writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Positive value without space : %d&quot;</span>, 56);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">No effect for negative values: -34
Positive value with space : 56
Positive value without space : 56
</pre>
<h5 style="margin: 1.25em 0.5em 0.5em 8px; padding: 0px; border: 0px; outline: 0px; font-size: 1.25em; vertical-align: baseline; background-color: transparent; font-family: sans-serif; font-weight: bold; color: rgb(0, 0, 51); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Positional parameters</h5>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
We have seen above that the parameters are associated one by one with the
specifiers in the format string. It is possible to use position numbers within
format specifiers. This enables associating the specifiers with specific
parameters. Parameters are numbered in increasing fashion, starting with 1. The
parameter numbers are specified immediately after the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%</code><span class="Apple-converted-space">&nbsp;</span>character,
followed by a<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">$</code>:</p>
<pre class="mono" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">% <i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;"><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: rgb(255, 255, 136); background-position: initial initial; background-repeat: initial initial;">position$</span> flags width precision format_character</code></i></span>
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
An advantage of positional parameters is being able to use the same parameter in
more than one places in the same format string:</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;%1$d %1$x %1$o %1$b&quot;</span>, 42);
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
The format string above uses the parameter numbered 1 within four specifiers to
print it in decimal, hexadecimal, octal, and binary formats:</p>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">42 2a 52 101010
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Another application of positional parameters is supporting multiple human
languages. When referred by position numbers, parameters can be moved anywhere
within the specific format string for a given human language. For example, the
number of students of a given classroom can be printed as in the following:</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> writefln(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;There are %s students in room %s.&quot;</span>, count, room);
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">There are 20 students in room 1A.
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Let&#39;s assume that the program must also support Turkish. In this case the format
string needs be selected according to the active language. The following method
takes advantage of the ternary operator:</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">auto</span> format = (language == <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;en&quot;</span>
? <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;There are %s students in room %s.&quot;</span>
: <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;%s sınıfında %s öğrenci var.&quot;</span>);
writefln(format, count, room);
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Unfortunately, when the parameters are associated one by one, the classroom and
student count information appear in reverse order in the Turkish message; the
room information is where the count should be and the count is where the room
should be:</p>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">20 sınıfında 1A öğrenci var. <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">← Wrong: means &quot;room 20&quot;, and &quot;1A students&quot;!</span>
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
To avoid this, the parameters can be specified by numbers as<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">1$</code><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">2$</code>to
associate each specifier with the exact parameter:</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"> <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">auto</span> format = (language == <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;en&quot;</span>
? <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;There are %<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(255, 255, 136); background-position: initial initial; background-repeat: initial initial;">1$</span>s students in room %<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(255, 255, 136); background-position: initial initial; background-repeat: initial initial;">2$</span>s.&quot;</span>
: <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;%<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(255, 255, 136); background-position: initial initial; background-repeat: initial initial;">2$</span>s sınıfında %<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(255, 255, 136); background-position: initial initial; background-repeat: initial initial;">1$</span>s öğrenci var.&quot;</span>);
writefln(format, count, room);
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Now the parameters appear in the proper order, regardless of the language
selected:</p>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">There are 20 students in room 1A.
</pre>
<pre class="shell" style="margin: 0.5em 1em 1em; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(224, 224, 224); font-weight: bold; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">1A sınıfında 20 öğrenci var.
</pre>
<h5 style="margin: 1.25em 0.5em 0.5em 8px; padding: 0px; border: 0px; outline: 0px; font-size: 1.25em; vertical-align: baseline; background-color: transparent; font-family: sans-serif; font-weight: bold; color: rgb(0, 0, 51); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">
format</code></h5>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Formatted output is available by the<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">format()</code><span class="Apple-converted-space">&nbsp;</span>function
of the<code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">std.string</code><span class="Apple-converted-space">&nbsp;</span>module
as well.<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">format()</code><span class="Apple-converted-space">&nbsp;</span>works
the same as<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">writef()</code><span class="Apple-converted-space">&nbsp;</span>but
it<span class="Apple-converted-space">&nbsp;</span><i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">returns</i><span class="Apple-converted-space">&nbsp;</span>the
result as a<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">string</code><span class="Apple-converted-space">&nbsp;</span>instead
of printing it to the output:</p>
<pre class="d_code" style="margin: 0.5em 1em 0.75em 16px; padding: 0.5em; border: 1px dotted rgb(153, 204, 153); outline: 0px; font-size: 1em; vertical-align: baseline; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;"><span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">import</span> std.stdio;
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">import</span> std.string;
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">void</span> main()
{
write(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;What is your name? &quot;</span>);
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">auto</span> name = chomp(readln());
<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: blue; background-position: initial initial; background-repeat: initial initial;">auto</span> result = <span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: rgb(255, 255, 136); background-position: initial initial; background-repeat: initial initial;">format</span>(<span style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 13px; vertical-align: baseline; background-color: transparent; color: red; background-position: initial initial; background-repeat: initial initial;">&quot;Hello %s!&quot;</span>, name);
}
</pre>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
The program can make use of that result in later expressions.</p>
<h5 style="margin: 1.25em 0.5em 0.5em 8px; padding: 0px; border: 0px; outline: 0px; font-size: 1.25em; vertical-align: baseline; background-color: transparent; font-family: sans-serif; font-weight: bold; color: rgb(0, 0, 51); font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
Exercises</h5>
<ol style="margin: 1em 1em 0.75em 1.5em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
Write a program that reads a value and prints it in the hexadecimal system.</li>
<li style="margin: 0.5em 0px 0px 1em; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
Write a program that reads a floating point value and prints it as
percentage value with two digits after the dot. For example, if the value is
1.2345, it should print<span class="Apple-converted-space">&nbsp;</span><code class="d_inline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 1.2em; vertical-align: baseline; background-color: transparent; font-weight: bold; color: rgb(0, 34, 34); background-position: initial initial; background-repeat: initial initial;">%1.23</code>.</li>
</ol>
<p style="margin: 0.75em 1em 0.75em 16px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 19px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<a href="http://ddili.org/ders/d.en/formatted_output.cozum.html" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; color: purple; text-decoration: none; background-position: initial initial; background-repeat: initial initial;" target="ddili_cozum">
<i style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 16px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">
... the solutions</i></a></p>
<div id="ders_nav_son" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 0.9em; vertical-align: baseline; background-color: transparent; float: right; width: 190px; text-align: center; color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
[<span class="Apple-converted-space">&nbsp;</span><a href="literals.html" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; color: purple; text-decoration: none; background-position: initial initial; background-repeat: initial initial;">Prev&nbsp;</a>]
&nbsp; [<span class="Apple-converted-space">&nbsp;</span><a href="formattedinput.html" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; color: purple; text-decoration: none; background-position: initial initial; background-repeat: initial initial;">Next&nbsp;</a>]</div>
</body>
</html>
D
1
https://gitee.com/lucifer2031/Programming-in-D-in-Chinese.git
git@gitee.com:lucifer2031/Programming-in-D-in-Chinese.git
lucifer2031
Programming-in-D-in-Chinese
Programming-in-D-in-Chinese
master

搜索帮助