Basic Pascal Tutorial/Chapter 1/Standard Functions/ja
한국어 · Deutsch · English · Français · Български · Русский · 中文(中国) · 日本語
1F - 標準関数 (著者: Tao Yue, 状態: 原文のまま)
Pascal には利用可能な標準的数学関数がいくつか用意されている。 たとえば、パイ(π)のsinの値を求めるのは以下のようになる。
value := sin (3.1415926535897932);sin関数は3角法のすべての関数がそうであるように、ラジアンで表現される角度に適用できることに注意しよう。問題がなければ、値は0になるはずである。
関数は関数名のあとにカッコで引数をつけて呼び出される。標準の Pascal 関数には以下のものが含まれる。
| Function | Description | Argument type | Return type |
|---|---|---|---|
| abs | 絶対値 | real or integer | 引数と同じ型 |
| arctan | ラジアンでのアークタンジェント(arctan) | real or integer | real |
| cos | ラジアンでコサイン(cosine) | real or integer | real |
| exp | 指数(e to the given power) | real or integer | real |
| ln | 自然対数 | real or integer | real |
| round | もっと近い整数への丸め | real | integer |
| sin | ラジアンでのサイン(sin) | real or integer | real |
| sqr | 二乗 (指数 2) | real or integer | 引数と同じ型 |
| sqrt | 平方根 (指数 1/2) | real or integer | real |
| trunc | 端数の切り捨て | real or integer | integer |
順序型データタイプ(integer or char)は、その前後に明らかな値を持ち、次のような関数が利用できる。
| Function | Description | Argument type | Return type |
|---|---|---|---|
| chr | ASCII 値で表した文字 | integer | char |
| ord | 順序値 | integer or char | integer |
| pred | 前の値 | integer or char | 引数と同じ型 |
| succ | 後の値 | integer or char | 引数と同じ型 |
実数は順序型データタイプではない。なぜなら前後に明らかな値をもっていないからである。56.0の次の値は何だろうか? 56.1だろうか、あるいは56.01、56.001、それとも56.0001だろうか?
しかし、整数の56に対しては明らかな前の値55と明らかな次の値57が存在している。
同じことが文字にも言える。
'b'
次の文字: 'c'
前の文字: 'a'上に挙げたのは完全なリストではない。現在の Pascal コンパイラはあらゆる種類の目的のために数千もの関数を含んでいるのである。さらに知りたければ自分のコンパイラの資料をチェックすると良い。
| previous | contents | next |
From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Standard Functions/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.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
