From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../reference/global_objects/math/sqrt/index.html | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/math/sqrt/index.html (limited to 'files/ja/web/javascript/reference/global_objects/math/sqrt/index.html') diff --git a/files/ja/web/javascript/reference/global_objects/math/sqrt/index.html b/files/ja/web/javascript/reference/global_objects/math/sqrt/index.html new file mode 100644 index 0000000000..2172c163fc --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/math/sqrt/index.html @@ -0,0 +1,83 @@ +--- +title: Math.sqrt() +slug: Web/JavaScript/Reference/Global_Objects/Math/sqrt +tags: + - JavaScript + - Math + - Method + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/sqrt +--- +
{{JSRef}}
+ +

Math.sqrt() 関数は、ある数の平方根を返します。すなわち、

+ +

x0,Math.sqrt(x)=x=the uniquey0such thaty2=x\forall x \geq 0, \mathtt{Math.sqrt(x)} = \sqrt{x} = \text{the unique} \; y \geq 0 \; \text{such that} \; y^2 = x

+ +
{{EmbedInteractiveExample("pages/js/math-sqrt.html")}}
+ + + +

構文

+ +
Math.sqrt(x)
+ +

引数

+ +
+
x
+
数値です。
+
+ +

返値

+ +

与えられた数値の平方根です。数値が負の場合、 {{jsxref("NaN")}} を返します。

+ +

解説

+ +

x の値が負の数であった場合、 Math.sqrt() は {{jsxref("NaN")}} を返します。

+ +

sqrt()Math の静的メソッドであるため、生成した Math オブジェクトのメソッドとしてではなく、常に Math.sqrt() として使用するようにしてください (Math はコンストラクターではありません)。

+ +

+ +

Math.sqrt() の使用

+ +
Math.sqrt(9); // 3
+Math.sqrt(2); // 1.414213562373095
+
+Math.sqrt(1);  // 1
+Math.sqrt(0);  // 0
+Math.sqrt(-1); // NaN
+Math.sqrt(-0); // -0
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('ESDraft', '#sec-math.sqrt', 'Math.sqrt')}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("javascript.builtins.Math.sqrt")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf