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/cbrt/index.html | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/math/cbrt/index.html (limited to 'files/ja/web/javascript/reference/global_objects/math/cbrt') diff --git a/files/ja/web/javascript/reference/global_objects/math/cbrt/index.html b/files/ja/web/javascript/reference/global_objects/math/cbrt/index.html new file mode 100644 index 0000000000..23f22f4e8d --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/math/cbrt/index.html @@ -0,0 +1,95 @@ +--- +title: Math.cbrt() +slug: Web/JavaScript/Reference/Global_Objects/Math/cbrt +tags: + - JavaScript + - Math + - Method + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt +--- +
{{JSRef}}
+ +

Math.cbrt() 関数は、引数として与えた数の立方根を返します。すなわち、

+ +

Math.cbrt(x)=x3=the uniqueysuch thaty3=x\mathtt{Math.cbrt(x)} = \sqrt[3]{x} = \text{the unique} \; y \; \text{such that} \; y^3 = x

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

構文

+ +
Math.cbrt(x)
+ +

引数

+ +
+
x
+
数値。
+
+ +

返値

+ +

与えられた数値の立方根です。

+ +

解説

+ +

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

+ +

ポリフィル

+ +

すべての x0x \geq 0 に対して、 x3=x1/3\sqrt[3]{x} = x^{1/3} が存在し、次の関数でエミュレートできます:

+ +
if (!Math.cbrt) {
+  Math.cbrt = (function(pow) {
+    return function cbrt(x){
+      // ensure negative numbers remain negative:
+      return x < 0 ? -pow(-x, 1/3) : pow(x, 1/3);
+    };
+  })(Math.pow); // localize Math.pow to increase efficiency
+}
+
+ +

+ +

Math.cbrt() の使用

+ +
Math.cbrt(NaN); // NaN
+Math.cbrt(-1); // -1
+Math.cbrt(-0); // -0
+Math.cbrt(-Infinity); // -Infinity
+Math.cbrt(0); // 0
+Math.cbrt(1); // 1
+Math.cbrt(Infinity); // Infinity
+Math.cbrt(null); // 0
+Math.cbrt(2);  // 1.2599210498948732
+
+ +

仕様書

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

ブラウザーの互換性

+ + + +

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

+ +

関連情報

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