Difference between revisions of "Basic Pascal Tutorial/Chapter 2/Formatting output/ja"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "{{Formatting output}} 2C - Formatting Output (author: Tao Yue, state: unchanged) Formatting output is quite easy. For each identifier or literal value on the argument list, ...")
 
m (bypass language bar/categorization template redirect [cf. discussion])
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Formatting output}}
+
{{Basic Pascal Tutorial/Chapter 2/Formatting output}}
  
2C - Formatting Output (author: Tao Yue, state: unchanged)
+
2C - 出力の書式指定 (著者: Tao Yue, 状態: 原文のまま修正なし)
  
Formatting output is quite easy. For each identifier or literal value on the argument list, use:
+
出力の書式しては非常に簡単である。引数リストの各識別子、あるいは文字値に以下を用いればよい。
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
Value : field_width
+
Value : フィールド幅
 
</syntaxhighlight>
 
</syntaxhighlight>
  
The output is right-justified in a field of the specified integer width. If the width is not long enough for the data, the width specification will be ignored and the data will be displayed in its entirety (except for real values — see below).
+
出力は指定された整数値の幅で右揃えになる。幅がデータに対して十分な長さがない場合には、幅指定は無視され、そのデータはそのままに表示される(実数値の場合は除く。以下を参照)。
  
Suppose we had:
+
以下のようなケースだとしよう。
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
write ('Hi':10, 5:4, 5673:2);
 
write ('Hi':10, 5:4, 5673:2);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
The output would be (that's eight spaces before the Hi and three spaces after):
+
出力は以下のようになる(すなわち、Hiの前に8個のスペース、その後に3個のスペース)
 
         Hi  55673
 
         Hi  55673
  
For real values, you can use the aforementioned syntax to display scientific notation in a specified field width, or you can convert to fixed decimal-point notation with:
+
実数値に対しては特定のフィールド幅で科学的表記を前述の構文で表現できる。あるいはそれを固定小数点表記に変換することもできる。
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
Value : field_width : decimal_field_width
+
Value : フィールド幅 : 小数点以下のフィールド幅
 
</syntaxhighlight>
 
</syntaxhighlight>
  
The field width is the total field width, including the decimal part. The whole number part is always displayed fully, so if you have not allocated enough space, it will be displayed anyway. However, if the number of decimal digits exceeds the specified decimal field width, the output will be displayed rounded to the specified number of places (though the variable itself is not changed).
+
ここのフィールド幅は全フィールド幅であり、小数点以下の部分も含んでいる。整数部は常にすべて表示される。従い、十分なスペースを割り当てていなくてもとにかく、整数部は表示される。しかし、小数点以下の部分が指定された小数点以下のフィールド幅を超えた場合には、出力は指定された桁で丸められて表示される(変数それ自体は変更されない)。
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
write (573549.56792:20:2);
 
write (573549.56792:20:2);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
would look like (with 11 spaces in front):
+
これは、前に11個のスペースが入り、次のように表示される。
 
             573549.57
 
             573549.57
  
 
{|style=color-backgroud="white" cellspacing="20"
 
{|style=color-backgroud="white" cellspacing="20"
|[[Output|previous]]   
+
|[[Basic Pascal Tutorial/Chapter 2/Output/ja|previous]]   
|[[Contents|contents]]  
+
|[[Basic Pascal Tutorial/Contents/ja|contents]]  
|[[Files|next]]
+
|[[Basic Pascal Tutorial/Chapter 2/Files/ja|next]]
 
|}
 
|}

Latest revision as of 16:18, 20 August 2022

български (bg) Deutsch (de) English (en) français (fr) 日本語 (ja) 中文(中国大陆)‎ (zh_CN)

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

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

Value : フィールド幅

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

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

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

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

        Hi   55673

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

Value : フィールド幅 : 小数点以下のフィールド幅

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

write (573549.56792:20:2);

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

           573549.57
previous contents next