A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Math/PI below:

Math.PI - JavaScript | MDN

Math.PI

Baseline Widely available

Math.PI プロパティは、円周と直径の比率、およそ 3.14159 を表します。

試してみましょう
function calculateCircumference(radius) {
  return 2 * Math.PI * radius;
}

console.log(Math.PI);
// Expected output: 3.141592653589793

console.log(calculateCircumference(10));
// Expected output: 62.83185307179586
値 𝙼𝚊𝚝𝚑.𝙿𝙸 = π ≈ 3.14159 \mathtt{Math.PI} = \pi \approx 3.14159 書込可能 不可 列挙可能 不可 設定可能 不可 解説

PI は Math オブジェクトの静的プロパティなので、 Math オブジェクトを生成してプロパティとして使用するのではなく、常に Math.PI として使用するようにしてください (Math はコンストラクターではありません)。

例 Math.PI の使用

次の関数は Math.PI を使用して、指定された半径を持つ円の円周を計算します。

function calculateCircumference(radius) {
  return Math.PI * (radius + radius);
}

calculateCircumference(1); // 6.283185307179586
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4