Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 2/Formatting output/ja

Sent here from Formatting output/ja.

Deutsch · English · Français · Български · 中文(中国) · 日本語

2C - 出力の書式指定 (著者: Tao Yue, 状態: 原文のまま修正なし)

出力の書式しては非常に簡単である。引数リストの各識別子、あるいは文字値に以下を用いればよい。

pascal
Value : ??????????????????

出力は指定された整数値の幅で右揃えになる。幅がデータに対して十分な長さがない場合には、幅指定は無視され、そのデータはそのままに表示される(実数値の場合は除く。以下を参照)。

以下のようなケースだとしよう。

pascal
write ('Hi':10, 5:4, 5673:2);

出力は以下のようになる(すなわち、Hiの前に8個のスペース、その後に3個のスペース)。

text
        Hi   55673

実数値に対しては特定のフィールド幅で科学的表記を前述の構文で表現できる。あるいはそれを固定小数点表記に変換することもできる。

pascal
Value : ?????????????????? : ????????????????????????????????????

ここのフィールド幅は全フィールド幅であり、小数点以下の部分も含んでいる。整数部は常にすべて表示される。従い、十分なスペースを割り当てていなくてもとにかく、整数部は表示される。しかし、小数点以下の部分が指定された小数点以下のフィールド幅を超えた場合には、出力は指定された桁で丸められて表示される(変数それ自体は変更されない)。

pascal
write (573549.56792:20:2);

これは、前に11個のスペースが入り、次のように表示される。

text
           573549.57
previous contents next

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 2/Formatting output/ja", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 5, last changed by WikiArchive .

Edited on wiki.freepascal.org by 3 people, 2015–2022

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
DerakunCreated page
Derakun
Derakun
Derakun
TrevFixed syntax highlighting (minor)
Kai BurghardtKai Burghardt moved page Formatting output/ja to Basic Pascal Tutorial/Chapter 2/Formatting output/ja: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: Perma... (minor)
Kai Burghardtbypass redirects [cf. discussion]
Kai Burghardtbypass [previously missed] redirect [cf. discussion]
Kai Burghardtbypass language bar/categorization template redirect [cf. discussion] (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.