From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../reference/global_objects/math/abs/index.html | 104 ++++++++++ .../reference/global_objects/math/acos/index.html | 103 ++++++++++ .../reference/global_objects/math/cbrt/index.html | 98 ++++++++++ .../reference/global_objects/math/ceil/index.html | 209 +++++++++++++++++++++ .../reference/global_objects/math/e/index.html | 84 +++++++++ .../reference/global_objects/math/exp/index.html | 90 +++++++++ .../reference/global_objects/math/floor/index.html | 171 +++++++++++++++++ .../global_objects/math/fround/index.html | 130 +++++++++++++ .../reference/global_objects/math/imul/index.html | 130 +++++++++++++ .../reference/global_objects/math/index.html | 155 +++++++++++++++ .../reference/global_objects/math/ln10/index.html | 84 +++++++++ .../reference/global_objects/math/ln2/index.html | 86 +++++++++ .../reference/global_objects/math/log/index.html | 104 ++++++++++ .../global_objects/math/log10e/index.html | 84 +++++++++ .../reference/global_objects/math/log2/index.html | 96 ++++++++++ .../reference/global_objects/math/log2e/index.html | 84 +++++++++ .../reference/global_objects/math/max/index.html | 110 +++++++++++ .../reference/global_objects/math/min/index.html | 103 ++++++++++ .../reference/global_objects/math/pi/index.html | 82 ++++++++ .../global_objects/math/random/index.html | 106 +++++++++++ .../reference/global_objects/math/round/index.html | 92 +++++++++ .../reference/global_objects/math/sign/index.html | 112 +++++++++++ .../reference/global_objects/math/sin/index.html | 97 ++++++++++ .../reference/global_objects/math/sinh/index.html | 96 ++++++++++ .../reference/global_objects/math/sqrt/index.html | 90 +++++++++ .../global_objects/math/sqrt1_2/index.html | 59 ++++++ .../reference/global_objects/math/sqrt2/index.html | 74 ++++++++ .../reference/global_objects/math/tan/index.html | 102 ++++++++++ .../reference/global_objects/math/tanh/index.html | 85 +++++++++ .../reference/global_objects/math/trunc/index.html | 96 ++++++++++ 30 files changed, 3116 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/math/abs/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/acos/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/cbrt/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/ceil/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/e/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/exp/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/floor/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/fround/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/imul/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/ln10/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/ln2/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/log/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/log10e/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/log2/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/log2e/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/max/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/min/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/pi/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/random/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/round/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sign/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sin/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sinh/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sqrt/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sqrt1_2/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/sqrt2/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/tan/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/tanh/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/math/trunc/index.html (limited to 'files/ko/web/javascript/reference/global_objects/math') diff --git a/files/ko/web/javascript/reference/global_objects/math/abs/index.html b/files/ko/web/javascript/reference/global_objects/math/abs/index.html new file mode 100644 index 0000000000..c66172647d --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/abs/index.html @@ -0,0 +1,104 @@ +--- +title: Math.abs() +slug: Web/JavaScript/Reference/Global_Objects/Math/abs +tags: + - JavaScript + - Math + - Method + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/abs +--- +
{{JSRef}}
+ +

Math.abs() 함수는 주어진 숫자의 절대값을 반환합니다. 즉,

+ +

Math.abs(x)=|x|={xifx>00ifx=0-xifx<0{\mathtt{\operatorname{Math.abs}(x)}} = {|x|} = \begin{cases} x & \text{if} \quad x \geq 0 \\ -x & \text{if} \quad x < 0 \end{cases}

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

구문

+ +
Math.abs(x)
+ +

매개변수

+ +
+
x
+
숫자.
+
+ +

반환 값

+ +

주어진 숫자의 절대값.

+ +

설명

+ +

abs()Math의 정적 메서드이므로, 사용자가 생성한 Math 객체의 메서드로 호출할 수 없고 항상 Math.abs()를 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +

예제

+ +

Math.abs()의 작동 방식

+ +

빈 객체, 하나 이상의 요소를 가진 배열, 숫자가 아닌 문자열, {{jsxref("undefined")}}나 빈 매개변수를 받으면 {{jsxref("NaN")}}을 반환합니다. {{jsxref("null")}}, 빈 문자열이나 빈 배열을 제공하면 0을 반환합니다.

+ +
Math.abs('-1');     // 1
+Math.abs(-2);       // 2
+Math.abs(null);     // 0
+Math.abs('');       // 0
+Math.abs([]);       // 0
+Math.abs([2]);      // 2
+Math.abs([1,2]);    // NaN
+Math.abs({});       // NaN
+Math.abs('string'); // NaN
+Math.abs();         // NaN
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.1', 'Math.abs')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.abs', 'Math.abs')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.abs', 'Math.abs')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/acos/index.html b/files/ko/web/javascript/reference/global_objects/math/acos/index.html new file mode 100644 index 0000000000..83cc67d786 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/acos/index.html @@ -0,0 +1,103 @@ +--- +title: Math.acos() +slug: Web/JavaScript/Reference/Global_Objects/Math/acos +tags: + - JavaScript + - Math + - Method + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/acos +--- +
{{JSRef}}
+ +

Math.acos() 함수는 주어진 수의 아크코사인 값을 숫자(라디안)로 반환합니다. 즉,

+ +

x[-1;1],Math.acos(x)=arccos(x)= the unique y[0;π]such thatcos(y)=x\forall x \in [{-1};1],\;\mathtt{\operatorname{Math.acos}(x)} = \arccos(x) = \text{ the unique } \; y \in [0; \pi] \, \text{such that} \; \cos(y) = x

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

구문

+ +
Math.acos(x)
+ +

매개변수

+ +
+
x
+
각도를 나타내는 라디안.
+
+ +

반환 값

+ +

-1과 1 사이의 값이 주어진 경우, 그 값의 아크코사인. 아닐 경우 {{jsxref("NaN")}}

+ +

설명

+ +

The Math.acos() method returns a numeric value between 0 and π radians for x between -1 and 1. If the value of x is outside this range, it returns {{jsxref("NaN")}}.

+ +

Because acos() is a static method of Math, you always use it as Math.acos(), rather than as a method of a Math object you created (Math is not a constructor).

+ +

예제

+ +

Using Math.acos()

+ +
Math.acos(-2);  // NaN
+Math.acos(-1);  // 3.141592653589793
+Math.acos(0);   // 1.5707963267948966
+Math.acos(0.5); // 1.0471975511965979
+Math.acos(1);   // 0
+Math.acos(2);   // NaN
+
+ +

For values less than -1 or greater than 1, Math.acos() returns {{jsxref("NaN")}}.

+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.2', 'Math.acos')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.acos', 'Math.acos')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.acos', 'Math.acos')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/cbrt/index.html b/files/ko/web/javascript/reference/global_objects/math/cbrt/index.html new file mode 100644 index 0000000000..20a5f3ee3a --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/cbrt/index.html @@ -0,0 +1,98 @@ +--- +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

+ +

구문

+ +
Math.cbrt(x)
+ +

매개변수

+ +
+
x
+
숫자.
+
+ +

반환 값

+ +

주어진 수의 세제곱근.

+ +

설명

+ +

cbrt()는 Math의 정적 메서드이므로, 사용자가 생성한 Math 객체의 메서드로 호출할 수 없고 항상 Math.cbrt()를 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +

예제

+ +

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.2599210498948734
+
+ +

폴리필

+ +

모든 x0x \geq 0에서 x3=x1/3\sqrt[3]{x} = x^{1/3} 이므로, Math.cbrt()는 다음 함수로 폴리필할 수 있습니다.

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

명세

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES6', '#sec-math.cbrt', 'Math.cbrt')}}{{Spec2('ES6')}}Initial definition.
{{SpecName('ESDraft', '#sec-math.cbrt', 'Math.cbrt')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/ceil/index.html b/files/ko/web/javascript/reference/global_objects/math/ceil/index.html new file mode 100644 index 0000000000..ee5998fa83 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/ceil/index.html @@ -0,0 +1,209 @@ +--- +title: Math.ceil() +slug: Web/JavaScript/Reference/Global_Objects/Math/ceil +translation_of: Web/JavaScript/Reference/Global_Objects/Math/ceil +--- +
{{JSRef}}
+ +
Math.ceil() 함수는 주어진 숫자보다 크거나 같은 숫자 중 가장 작은 숫자를 integer 로 반환합니다.
+ +
 
+ +

Syntax (문법)

+ +
Math.ceil(x)
+ +

Parameters (매개변수)

+ +
+
x
+
숫자
+
+ +

Return value (반환값)

+ +

주어진 숫자보다 크거나 같은 숫자 중 가장 작은 숫자

+ +

Description (설명)

+ +

ceil() 은 Math 의 정적 메소드이므로, 사용자가 생성하는 Math 객체의 메소드처럼 사용하지 않고, 언제나 Math.ceil() 의 형태로 사용 합니다. (Math 는 생성자가 아님)

+ +

Examples (예제)

+ +

Math.ceil() 사용 예

+ +

다음은 Math.ceil() 의 사용 예입니다.

+ +
Math.ceil(.95);    // 1
+Math.ceil(4);      // 4
+Math.ceil(7.004);  // 8
+Math.ceil(-0.95);  // -0
+Math.ceil(-4);     // -4
+Math.ceil(-7.004); // -7
+
+ +

소수점 처리

+ +
// Closure
+(function() {
+  /**
+   * Decimal adjustment of a number.
+   *
+   * @param {String}  type  The type of adjustment.
+   * @param {Number}  value The number.
+   * @param {Integer} exp   The exponent (the 10 logarithm of the adjustment base).
+   * @returns {Number} The adjusted value.
+   */
+  function decimalAdjust(type, value, exp) {
+    // If the exp is undefined or zero...
+    if (typeof exp === 'undefined' || +exp === 0) {
+      return Math[type](value);
+    }
+    value = +value;
+    exp = +exp;
+    // If the value is not a number or the exp is not an integer...
+    if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
+      return NaN;
+    }
+    // Shift
+    value = value.toString().split('e');
+    value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
+    // Shift back
+    value = value.toString().split('e');
+    return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
+  }
+
+  // Decimal round
+  if (!Math.round10) {
+    Math.round10 = function(value, exp) {
+      return decimalAdjust('round', value, exp);
+    };
+  }
+  // Decimal floor
+  if (!Math.floor10) {
+    Math.floor10 = function(value, exp) {
+      return decimalAdjust('floor', value, exp);
+    };
+  }
+  // Decimal ceil
+  if (!Math.ceil10) {
+    Math.ceil10 = function(value, exp) {
+      return decimalAdjust('ceil', value, exp);
+    };
+  }
+})();
+
+// Round
+Math.round10(55.55, -1);   // 55.6
+Math.round10(55.549, -1);  // 55.5
+Math.round10(55, 1);       // 60
+Math.round10(54.9, 1);     // 50
+Math.round10(-55.55, -1);  // -55.5
+Math.round10(-55.551, -1); // -55.6
+Math.round10(-55, 1);      // -50
+Math.round10(-55.1, 1);    // -60
+// Floor
+Math.floor10(55.59, -1);   // 55.5
+Math.floor10(59, 1);       // 50
+Math.floor10(-55.51, -1);  // -55.6
+Math.floor10(-51, 1);      // -60
+// Ceil
+Math.ceil10(55.51, -1);    // 55.6
+Math.ceil10(51, 1);        // 60
+Math.ceil10(-55.59, -1);   // -55.5
+Math.ceil10(-59, 1);       // -50
+
+ +

Specifications (사용법)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.6', 'Math.ceil')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.ceil', 'Math.ceil')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.ceil', 'Math.ceil')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility (브라우저 호환성)

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

See also (추가 참조)

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/e/index.html b/files/ko/web/javascript/reference/global_objects/math/e/index.html new file mode 100644 index 0000000000..d2d4060bed --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/e/index.html @@ -0,0 +1,84 @@ +--- +title: Math.E +slug: Web/JavaScript/Reference/Global_Objects/Math/E +tags: + - JavaScript + - Math + - Property + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/E +--- +
{{JSRef}}
+ +

Math.E 속성은 자연로그의 밑 값  e를 나타내며 약 2.718의 값을 가집니다.

+ +

Math.E=e2.718\mathtt{\mi{Math.E}} = e \approx 2.718

+ +
{{EmbedInteractiveExample("pages/js/math-e.html")}}
+ + + +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

EMath의 정적 속성이므로, 사용자가 생성한 Math 객체의 속성으로 접근할 수 없고 항상 Math.E를 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +

예제

+ +

Math.E 사용하기

+ +

다음 함수는 e 값을 반환합니다.

+ +
function getNapier() {
+  return Math.E;
+}
+
+getNapier(); // 2.718281828459045
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.1', 'Math.E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.e', 'Math.E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.e', 'Math.E')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/exp/index.html b/files/ko/web/javascript/reference/global_objects/math/exp/index.html new file mode 100644 index 0000000000..c00f391045 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/exp/index.html @@ -0,0 +1,90 @@ +--- +title: Math.exp() +slug: Web/JavaScript/Reference/Global_Objects/Math/exp +translation_of: Web/JavaScript/Reference/Global_Objects/Math/exp +--- +
{{JSRef}}
+ +

 Math.exp()함수는 x를 인수로 하는 ex 값을 반환합니다. 그리고 e는 {{jsxref("Math.E", "오일러 상수(또는 네이피어 상수)", "", 1)}}는 자연 로그의 밑입니다.

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

구문

+ +
Math.exp(x)
+ +

매개변수

+ +
+
x
+
숫자
+
+ +

반환 값

+ +

e는 {{jsxref("Math.E", "오일러 상수", "", 1)}}이고 x는 인수인 ex

+ +

Description

+ +

exp()Math의 정적 메소드이기 때문에 새로 작성한 Math 오브젝트 대신에 항상 Math.exp()의 형태로 써야 합니다. (Math는 생성자가 아닙니다.)

+ +

예시

+ +

 Math.exp() 사용 예

+ +
Math.exp(-1); // 0.36787944117144233
+Math.exp(0);  // 1
+Math.exp(1);  // 2.718281828459045
+
+ +

설명

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
설명상태비고
{{SpecName('ES1')}}{{Spec2('ES1')}}최초의 정의. JavaScript 1.0.에서 첫 시행.
{{SpecName('ES5.1', '#sec-15.8.2.8', 'Math.exp')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.exp', 'Math.exp')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.exp', 'Math.exp')}}{{Spec2('ESDraft')}}
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/floor/index.html b/files/ko/web/javascript/reference/global_objects/math/floor/index.html new file mode 100644 index 0000000000..cd749b07c8 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/floor/index.html @@ -0,0 +1,171 @@ +--- +title: Math.floor() +slug: Web/JavaScript/Reference/Global_Objects/Math/floor +tags: + - JavaScript + - Math + - Method + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/floor +--- +
{{JSRef}}
+ +

Math.floor() 함수는 주어진 숫자와 같거나 작은 정수 중에서 가장 큰 수를 반환합니다.

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

구문

+ +
Math.floor(x)
+ +

매개변수

+ +
+
x
+
숫자.
+
+ +

반환 값

+ +

주어진 수 이하의 가장 큰 정수.

+ +

설명

+ +

floor()Math의 정적 메서드이므로, 사용자가 생성한 Math 객체의 메서드로 호출할 수 없고 항상 Math.floor()를 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +
+

참고: Math.floor(null)은 {{jsxref("NaN")}} 대신 0을 반환합니다.

+
+ +

예제

+ +

Math.floor() 사용하기

+ +
Math.floor( 45.95); //  45
+Math.floor( 45.05); //  45
+Math.floor(  4   ); //   4
+Math.floor(-45.05); // -46
+Math.floor(-45.95); // -46
+
+ +

십진수 조절

+ +
// Closure
+(function() {
+  /**
+   * Decimal adjustment of a number.
+   *
+   * @param {String}  type  The type of adjustment.
+   * @param {Number}  value The number.
+   * @param {Integer} exp   The exponent (the 10 logarithm of the adjustment base).
+   * @returns {Number} The adjusted value.
+   */
+  function decimalAdjust(type, value, exp) {
+    // If the exp is undefined or zero...
+    if (typeof exp === 'undefined' || +exp === 0) {
+      return Math[type](value);
+    }
+    value = +value;
+    exp = +exp;
+    // If the value is not a number or the exp is not an integer...
+    if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
+      return NaN;
+    }
+    // Shift
+    value = value.toString().split('e');
+    value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
+    // Shift back
+    value = value.toString().split('e');
+    return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
+  }
+
+  // Decimal round
+  if (!Math.round10) {
+    Math.round10 = function(value, exp) {
+      return decimalAdjust('round', value, exp);
+    };
+  }
+  // Decimal floor
+  if (!Math.floor10) {
+    Math.floor10 = function(value, exp) {
+      return decimalAdjust('floor', value, exp);
+    };
+  }
+  // Decimal ceil
+  if (!Math.ceil10) {
+    Math.ceil10 = function(value, exp) {
+      return decimalAdjust('ceil', value, exp);
+    };
+  }
+})();
+
+// Round
+Math.round10(55.55, -1);   // 55.6
+Math.round10(55.549, -1);  // 55.5
+Math.round10(55, 1);       // 60
+Math.round10(54.9, 1);     // 50
+Math.round10(-55.55, -1);  // -55.5
+Math.round10(-55.551, -1); // -55.6
+Math.round10(-55, 1);      // -50
+Math.round10(-55.1, 1);    // -60
+// Floor
+Math.floor10(55.59, -1);   // 55.5
+Math.floor10(59, 1);       // 50
+Math.floor10(-55.51, -1);  // -55.6
+Math.floor10(-51, 1);      // -60
+// Ceil
+Math.ceil10(55.51, -1);    // 55.6
+Math.ceil10(51, 1);        // 60
+Math.ceil10(-55.59, -1);   // -55.5
+Math.ceil10(-59, 1);       // -50
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.9', 'Math.floor')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.floor', 'Math.floor')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.floor', 'Math.floor')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/fround/index.html b/files/ko/web/javascript/reference/global_objects/math/fround/index.html new file mode 100644 index 0000000000..6fd328a2db --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/fround/index.html @@ -0,0 +1,130 @@ +--- +title: Math.fround() +slug: Web/JavaScript/Reference/Global_Objects/Math/fround +tags: + - JavaScript + - Math + - Method + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/fround +--- +
{{JSRef}}
+ +

Math.fround() 함수는 single precision 포맷으로 표현할 수 있는 실수들 중에서 가장 가까운 숫자를 리턴합니다.

+ +

문법

+ +
Math.fround(x)
+ +

파라메터

+ +
+
x
+
숫자.
+
+ +

설명

+ +

fround()Math 객체의 정적 메소드이기 때문에, 반드시 Math.fround() 같은 형태로 사용해야 합니다. Math 객체를 직접 만들어서 호출하는 방식으로 사용하지 않습니다 (Math 는 생성자가 아닙니다).

+ +

예제

+ +

Math.fround() 사용법

+ +
Math.fround(0);     // 0
+Math.fround(1);     // 1
+Math.fround(1.337); // 1.3370000123977661
+Math.fround(1.5);   // 1.5
+Math.fround(NaN);   // NaN
+
+ +

Polyfill

+ +

만약 {{jsxref("Float32Array")}} 가 지원된다면, Math.fround() 를 다음 함수로 흉내낼 수 있습니다.

+ +
Math.fround = Math.fround || (function (array) {
+  return function(x) {
+    return array[0] = x, array[0];
+  };
+})(Float32Array(1));
+
+ +

스펙

+ + + + + + + + + + + + + + + + + + + +
스펙상태비고
{{SpecName('ES6', '#sec-math.fround', 'Math.fround')}}{{Spec2('ES6')}}초기 정의.
{{SpecName('ESDraft', '#sec-math.fround', 'Math.fround')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("38")}}{{CompatGeckoDesktop("26")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}8
+
+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/imul/index.html b/files/ko/web/javascript/reference/global_objects/math/imul/index.html new file mode 100644 index 0000000000..e5f7a919ab --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/imul/index.html @@ -0,0 +1,130 @@ +--- +title: Math.imul() +slug: Web/JavaScript/Reference/Global_Objects/Math/imul +tags: + - JavaScript + - Math + - Method + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/imul +--- +
{{JSRef}}
+ +

Math.imul() 함수는 C 언어와 같은 양식으로 2개 파라메터의 32-bit 곱셈 결과를 리턴합니다.

+ +

문법

+ +
Math.imul(a, b)
+ +

파라메터

+ +
+
a
+
첫 번째 숫자.
+
b
+
두 번째 숫자.
+
+ +

설명

+ +

Math.imul() 를 쓰면 C 언어와 같은 양식의 빠른 32-bit 정수 곱셈이 가능합니다. 이 기능은 Emscripten 같은 프로젝트에 유용합니다. imul()Math 객체의 정적 메소드이기 때문에, Math 객체를 직접 만들어서 사용하지 않고 (Math 는 생성자가 아닙니다), Math.imul() 같은 형태로 사용합니다.

+ +

예제

+ +

Math.imul() 사용법

+ +
Math.imul(2, 4);          // 8
+Math.imul(-1, 8);         // -8
+Math.imul(-2, -2);        // 4
+Math.imul(0xffffffff, 5); // -5
+Math.imul(0xfffffffe, 5); // -10
+
+ +

Polyfill

+ +

다음과 같은 함수로 Math.imul() 을 흉내낼 수 있습니다.

+ +
Math.imul = Math.imul || function(a, b) {
+  var ah = (a >>> 16) & 0xffff;
+  var al = a & 0xffff;
+  var bh = (b >>> 16) & 0xffff;
+  var bl = b & 0xffff;
+  // the shift by 0 fixes the sign on the high part
+  // the final |0 converts the unsigned value into a signed value
+  return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
+};
+
+ +

스펙

+ + + + + + + + + + + + + + + + + + + +
스펙상태비고
{{SpecName('ES6', '#sec-math.imul', 'Math.imul')}}{{Spec2('ES6')}}초기 정의.
{{SpecName('ESDraft', '#sec-math.imul', 'Math.imul')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("28")}}{{CompatGeckoDesktop("20")}}{{CompatUnknown}}{{CompatOpera("16")}}{{CompatSafari("7")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("20")}}{{CompatUnknown}}{{CompatUnknown}}7
+
diff --git a/files/ko/web/javascript/reference/global_objects/math/index.html b/files/ko/web/javascript/reference/global_objects/math/index.html new file mode 100644 index 0000000000..3ce1a0638c --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/index.html @@ -0,0 +1,155 @@ +--- +title: Math +slug: Web/JavaScript/Reference/Global_Objects/Math +tags: + - JavaScript + - Math + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math +--- +
{{JSRef}}
+ +

Math는 수학적인 상수와 함수를 위한 속성과 메서드를 가진 내장 객체입니다. 함수 객체가 아닙니다.

+ +

Math는 {{jsxref("Number")}} 자료형만 지원하며 {{jsxref("BigInt")}}와는 사용할 수 없습니다.

+ +

설명

+ +

다른 전역 객체와 달리 Math는 생성자가 아닙니다. Math의 모든 속성과 메서드는 정적입니다. 파이 상수는 Math.PI로 참조할 수 있고, 사인 함수는 매개변수 x에 대해 Math.sin(x)와 같이 호출할 수 있습니다. 상수는 JavaScript에서 가능한 최대 실수 정밀도로 정의되어 있습니다.

+ +

속성

+ +
+
{{jsxref("Math.E")}}
+
+

오일러의 상수이며 자연로그의 밑. 약 2.718.

+
+
{{jsxref("Math.LN2")}}
+
+

2의 자연로그. 약 0.693.

+
+
{{jsxref("Math.LN10")}}
+
10의 자연로그. 약 2.303.
+
{{jsxref("Math.LOG2E")}}
+
밑이 2인 로그 E. 약 1.443.
+
{{jsxref("Math.LOG10E")}}
+
밑이 10인 로그 E. 약 0.434.
+
{{jsxref("Math.PI")}}
+
원의 둘레와 지름의 비율. 약 3.14159.
+
{{jsxref("Math.SQRT1_2")}}
+
½의 제곱근. 약 0.707.
+
{{jsxref("Math.SQRT2")}}
+
2의 제곱근. 약 1.414.
+
+ +

메서드

+ +
+

참고: 삼각 함수(sin()cos(), tan(), asin(), acos(), atan(), atan2())는 매개변수와 반환값 모두 호도법(라디안)을 사용합니다.

+ +

라디안 값을 각도 값으로 변환하려면 (Math.PI / 180)으로 나누세요. 반대로 각도 값에 곱하면 라디안 값이 됩니다.

+
+ +
+

참고: 많은 수의 Math 함수 정확도는 구현에 따라 다를 수 있습니다. 즉, 각 브라우저의 결과가 다를 수 있으며, 서로 같은 JS 엔진이라도 운영체제나 아키텍쳐에 따라서 불일치하는 값을 반환할 수 있습니다.

+
+ +
+
{{jsxref("Global_Objects/Math/abs", "Math.abs(x)")}}
+
숫자의 절댓값을 반환합니다.
+
{{jsxref("Global_Objects/Math/acos", "Math.acos(x)")}}
+
숫자의 아크코사인 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/acosh", "Math.acosh(x)")}} 
+
숫자의 쌍곡아크코사인 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/asin", "Math.asin(x)")}}
+
숫자의 아크사인 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/asinh", "Math.asinh(x)")}} 
+
숫자의 쌍곡아크사인 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/atan", "Math.atan(x)")}}
+
숫자의 아크탄젠트 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/atanh", "Math.atanh(x)")}} 
+
숫자의 쌍곡아크탄젠트 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/atan2", "Math.atan2(y, x)")}}
+
인수 몫의 아크탄젠트 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/cbrt", "Math.cbrt(x)")}} 
+
숫자의 세제곱근을 반환합니다.
+
{{jsxref("Global_Objects/Math/ceil", "Math.ceil(x)")}}
+
인수보다 크거나 같은 수 중에서 가장 작은 정수를 반환합니다.
+
{{jsxref("Global_Objects/Math/clz32", "Math.clz32(x)")}} 
+
주어진 32비트 정수의 선행 0 개수를 반환합니다.
+
{{jsxref("Global_Objects/Math/cos", "Math.cos(x)")}}
+
숫자의 코사인 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/cosh", "Math.cosh(x)")}} 
+
숫자의 쌍곡코사인 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/exp", "Math.exp(x)")}}
+
Ex 를 반환합니다. x는 인수이며 E 는 오일러 상수(2.718...) 또는 자연로그의 밑입니다.
+
{{jsxref("Global_Objects/Math/expm1", "Math.expm1(x)")}} 
+
exp(x)에서 1을 뺀 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/floor", "Math.floor(x)")}}
+
인수보다 작거나 같은 수 중에서 가장 큰 정수를 반환합니다.
+
{{jsxref("Global_Objects/Math/fround", "Math.fround(x)")}} 
+
인수의 가장 가까운 단일 정밀도 표현을 반환합니다.
+
{{jsxref("Global_Objects/Math/hypot", "Math.hypot([x[, y[, …]]])")}} 
+
인수의 제곱합의 제곱근을 반환합니다.
+
{{jsxref("Global_Objects/Math/imul", "Math.imul(x, y)")}} 
+
두 32비트 정수의 곱을 반환합니다.
+
{{jsxref("Global_Objects/Math/log", "Math.log(x)")}}
+
숫자의 자연로그(loge 또는 ln) 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/log1p", "Math.log1p(x)")}} 
+
숫자 x에 대해 1 + x의 자연로그(loge 또는 ln) 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/log10", "Math.log10(x)")}} 
+
숫자의 밑이 10인 로그를 반환합니다.
+
{{jsxref("Global_Objects/Math/log2", "Math.log2(x)")}} 
+
숫자의 밑이 2인 로그를 반환합니다.
+
{{jsxref("Global_Objects/Math/max", "Math.max([x[, y[, …]]])")}}
+
0개 이상의 인수에서 제일 큰 수를 반환합니다.
+
{{jsxref("Global_Objects/Math/min", "Math.min([x[, y[, …]]])")}}
+
0개 이상의 인수에서 제일 작은 수를 반환합니다.
+
{{jsxref("Global_Objects/Math/pow", "Math.pow(x, y)")}}
+
x의 y 제곱을 반환합니다.
+
{{jsxref("Global_Objects/Math/random", "Math.random()")}}
+
0과 1 사이의 난수를 반환합니다.
+
{{jsxref("Global_Objects/Math/round", "Math.round(x)")}}
+
숫자에서 가장 가까운 정수를 반환합니다.
+
{{jsxref("Global_Objects/Math/sign", "Math.sign(x)")}} 
+
x의 양의 수인지 음의 수인지 나타내는 부호를 반환합니다.
+
{{jsxref("Global_Objects/Math/sin", "Math.sin(x)")}}
+
숫자의 사인 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/sinh", "Math.sinh(x)")}} 
+
숫자의 쌍곡사인 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/sqrt", "Math.sqrt(x)")}}
+
숫자의 제곱근을 반환합니다.
+
{{jsxref("Global_Objects/Math/tan", "Math.tan(x)")}}
+
숫자의 탄젠트 값을 반환합니다.
+
{{jsxref("Global_Objects/Math/tanh", "Math.tanh(x)")}} 
+
숫자의 쌍곡탄젠트 값을 반환합니다.
+
Math.toSource() {{non-standard_inline}}
+
문자열 "Math"를 반환합니다.
+
{{jsxref("Global_Objects/Math/trunc", "Math.trunc(x)")}} 
+
숫자의 정수 부분을 반환합니다.
+
+ +

명세

+ + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-math-object', 'Math')}}
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/ln10/index.html b/files/ko/web/javascript/reference/global_objects/math/ln10/index.html new file mode 100644 index 0000000000..57ab837e50 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/ln10/index.html @@ -0,0 +1,84 @@ +--- +title: Math.LN10 +slug: Web/JavaScript/Reference/Global_Objects/Math/LN10 +tags: + - JavaScript + - Math + - Property + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/LN10 +--- +
{{JSRef}}
+ +

Math.LN10 속성은 10의 자연로그 값, 약 2.302의 값을 가집니다.

+ +

Math.LN10=ln(10)2.302\mathtt{\mi{Math.LN10}} = \ln(10) \approx 2.302

+ +
{{EmbedInteractiveExample("pages/js/math-ln10.html")}}
+ + + +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

LN10Math의 정적 속성이므로, 사용자가 생성한 Math 객체의 속성으로 접근할 수 없고 항상 Math.LN10을 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +

예제

+ +

Math.LN10 사용하기

+ +

다음 함수는 10의 자연 로그 값을 반환합니다.

+ +
function getNatLog10() {
+  return Math.LN10;
+}
+
+getNatLog10(); // 2.302585092994046
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.2', 'Math.LN10')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.ln10', 'Math.LN10')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.ln10', 'Math.LN10')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/ln2/index.html b/files/ko/web/javascript/reference/global_objects/math/ln2/index.html new file mode 100644 index 0000000000..202558fd59 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/ln2/index.html @@ -0,0 +1,86 @@ +--- +title: Math.LN2 +slug: Web/JavaScript/Reference/Global_Objects/Math/LN2 +tags: + - JavaScript + - Math + - Property + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/LN2 +--- +
{{JSRef}}
+ +

The Math.LN2 property represents the natural logarithm of 2, approximately 0.693:

+ +

Math.LN2 속성은 2의 자연로그 값, 약 0.693의 값을 가집니다.

+ +

Math.LN2=ln(2)0.693\mathtt{\mi{Math.LN2}} = \ln(2) \approx 0.693

+ +
{{EmbedInteractiveExample("pages/js/math-ln2.html")}}
+ + + +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

LN2Math의 정적 속성이므로, 사용자가 생성한 Math 객체의 속성으로 접근할 수 없고 항상 Math.LN2를 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +

Examples

+ +

Math.LN2 사용하기

+ +

다음 함수는 2의 자연 로그 값을 반환합니다.

+ +
function getNatLog2() {
+  return Math.LN2;
+}
+
+getNatLog2(); // 0.6931471805599453
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.3', 'Math.LN2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.ln2', 'Math.LN2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.ln2', 'Math.LN2')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/log/index.html b/files/ko/web/javascript/reference/global_objects/math/log/index.html new file mode 100644 index 0000000000..a343fa27a6 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/log/index.html @@ -0,0 +1,104 @@ +--- +title: Math.log() +slug: Web/JavaScript/Reference/Global_Objects/Math/log +translation_of: Web/JavaScript/Reference/Global_Objects/Math/log +--- +
{{JSRef}}
+ +

Math.log() 함수는 자연 로가리즘은 ({{jsxref("Math.E", "e")}} 를 기초) 의 수를 계산합니다, 이건 다음의

+ +

x>0,Math.log(x)=ln(x)=the uniqueysuch thatey=x\forall x > 0, \mathtt{\operatorname{Math.log}(x)} = \ln(x) = \text{고유값} \; y \; \text{같이} \; e^y = x

+ +

자바스크립트 Math.log() 함수는 ln(x) 수학적으로 같습니다.

+ +

문법

+ +
Math.log(x)
+ +

인자

+ +
+
x
+
실수값.
+
+ +

반환값

+ +

자연 로가리즘은 ({{jsxref("Math.E", "e")}} 를 기초) 실수값으로 줍니다. 마이너스 실수값, {{jsxref("NaN")}} 계산됩니다.

+ +

설명

+ +

만일 값 x 가 마이너스라면, 항상 다음값이 계산됩니다 {{jsxref("NaN")}}.

+ +

왜그렇냐면 Math의 log() 가 정적 메서드이기 때문,에 매번 다음처럼 Math.log() 써야합니다 (생성자로 초기화된 Math 개체가 아니기 때문입니다).

+ +

자연로그 2 나 10, 상수로쓸때 {{jsxref("Math.LN2")}} or {{jsxref("Math.LN10")}} . 로가리즘 기초값 2 나 10, 쓸때는 {{jsxref("Math.log2()")}} 혹은 {{jsxref("Math.log10()")}} . 로가리즘 다른 기초값은 Math.log(x) / Math.log(기초값) 처럼 예제참고; 미리계산하여 1 / Math.log(기초값) 할 수 있습니다.

+ +

예제

+ +

Math.log() 사용

+ +
Math.log(-1); // NaN, 정의범위 초과
+Math.log(0);  // -Infinity, 무한
+Math.log(1);  // 0
+Math.log(10); // 2.302585092994046
+
+ +

Math.log() 다른 기초값 사용

+ +

이 함수는 로가리즘 y 에 대한것으로 기초값 x (ie. logxy\log_x y): 입니다

+ +
function getBaseLog(x, y) {
+  return Math.log(y) / Math.log(x);
+}
+
+ +

다음을 실행하면 getBaseLog(10, 1000) 다음 2.9999999999999996 계산되는데 적당히 반올림하니다, 거의 3 에 가깝습니다.

+ +

명세서

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.10', 'Math.log')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.log', 'Math.log')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.log', 'Math.log')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/log10e/index.html b/files/ko/web/javascript/reference/global_objects/math/log10e/index.html new file mode 100644 index 0000000000..bb864c8aa3 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/log10e/index.html @@ -0,0 +1,84 @@ +--- +title: Math.LOG10E +slug: Web/JavaScript/Reference/Global_Objects/Math/LOG10E +tags: + - JavaScript + - Math + - Property + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/LOG10E +--- +
{{JSRef}}
+ +

Math.LOG10E 속성은 e의 로그 10 값, 약 0.434의 값을 가집니다.

+ +

Math.LOG10E=log10(e)0.434\mathtt{\mi{Math.LOG10E}} = \log_10(e) \approx 0.434

+ +
{{EmbedInteractiveExample("pages/js/math-log10e.html")}}
+ + + +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

LOG10EMath의 정적 속성이므로, 사용자가 생성한 Math 객체의 속성으로 접근할 수 없고 항상 Math.LOG10E를 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +

예제

+ +

Math.LOG10E 사용하기

+ +

다음 함수는 e의 로그 10 값을 반환합니다.

+ +
function getLog10e() {
+  return Math.LOG10E;
+}
+
+getLog10e(); // 0.4342944819032518
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.5', 'Math.LOG10E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.log10e', 'Math.LOG10E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.log10e', 'Math.LOG10E')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

참조

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/log2/index.html b/files/ko/web/javascript/reference/global_objects/math/log2/index.html new file mode 100644 index 0000000000..7cfd72531c --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/log2/index.html @@ -0,0 +1,96 @@ +--- +title: Math.log2() +slug: Web/JavaScript/Reference/Global_Objects/Math/log2 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/log2 +--- +
{{JSRef}}
+ +

 Math.log2() 함수는 숫자를 log2(숫자)로 반환합니다.

+ +

x>0,Math.log2(x)=log2(x)=the uniqueysuch that2y=x\forall x > 0, \mathtt{\operatorname{Math.log2}(x)} = \log_2(x) = \text{the unique} \; y \; \text{such that} \; 2^y = x

+ +

문법

+ +
Math.log2(x)
+ +

매개변수

+ +
+
x
+
숫자.
+
+ +

반환 값

+ +

주어진 숫자는 log2(숫자)로 계산합니다. 만약 숫자가 음수라면 {{jsxref("NaN")}}를 반환합니다.

+ +

설명

+ +

만약 x 의 값이 0보다 작다면(음수) 값은 항상 {{jsxref("NaN")}}로 반환합니다.

+ +

log2()는 Math의 정적 메서드이므로 만든 Math 객체의 메서드가 아니라 항상 Math.log2()함수를 사용해야합니다. (Math는 생성자가 없습니다.)

+ +

이 함수는 Math.log(x) / Math.log(2)와 같습니다.

+ +

따라서 log2(e)는 {{jsxref("Math.LOG2E")}}와 같습니다. 

+ +

그리고 위 함수는 1 / {{jsxref("Math.LN2")}}과 같습니다.

+ +

예제

+ +

Math.log2()

+ +
Math.log2(3);    // 1.584962500721156
+Math.log2(2);    // 1
+Math.log2(1);    // 0
+Math.log2(0);    // -Infinity
+Math.log2(-2);   // NaN
+Math.log2(1024); // 10
+
+ +

Polyfill

+ +

This Polyfill emulates the Math.log2 function. Note that it returns imprecise values on some inputs (like 1 << 29), wrap into {{jsxref("Math.round()")}} if working with bit masks.

+ +
Math.log2 = Math.log2 || function(x) {
+  return Math.log(x) * Math.LOG2E;
+};
+
+ +

표준

+ + + + + + + + + + + + + + + + + + + +
표준상태비고
{{SpecName('ES2015', '#sec-math.log2', 'Math.log2')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-math.log2', 'Math.log2')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

참조

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/log2e/index.html b/files/ko/web/javascript/reference/global_objects/math/log2e/index.html new file mode 100644 index 0000000000..244224df3d --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/log2e/index.html @@ -0,0 +1,84 @@ +--- +title: Math.LOG2E +slug: Web/JavaScript/Reference/Global_Objects/Math/LOG2E +tags: + - JavaScript + - Math + - Property + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/LOG2E +--- +
{{JSRef}}
+ +

Math.LOG2E 속성은 e의 로그 2 값, 약 1.442의 값을 가집니다.

+ +

Math.LOG2E=log2(e)1.442\mathtt{\mi{Math.LOG2E}} = \log_2(e) \approx 1.442

+ +
{{EmbedInteractiveExample("pages/js/math-log2e.html")}}
+ + + +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

LOG2EMath의 정적 속성이므로, 사용자가 생성한 Math 객체의 속성으로 접근할 수 없고 항상 Math.LOG2E를 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +

설명

+ +

Math.LOG2E 사용하기

+ +

다음 함수는 e의 로그 2 값을 반환합니다.

+ +
function getLog2e() {
+  return Math.LOG2E;
+}
+
+getLog2e(); // 1.4426950408889634
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.4', 'Math.LOG2E')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.log2e', 'Math.LOG2E')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.log2e', 'Math.LOG2E')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/max/index.html b/files/ko/web/javascript/reference/global_objects/math/max/index.html new file mode 100644 index 0000000000..e315e5027b --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/max/index.html @@ -0,0 +1,110 @@ +--- +title: Math.max() +slug: Web/JavaScript/Reference/Global_Objects/Math/max +tags: + - Math + - 메소드 + - 자바스크립트 + - 참조 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/max +--- +
{{JSRef}}
+ +

Math.max()함수는 입력값으로 받은 0개 이상의 숫자 중 가장 큰 숫자를 반환합니다.

+ +

문법

+ +
Math.max([값1[, 값2[, ...]]])
+ +

매개변수

+ +
+
값1, 값2, ...
+
숫자들.
+
+ +

반환 값

+ +

입력된 숫자 중 가장 큰 숫자를 반환합니다. 만약 인수 중 하나라도 숫자로 변환하지 못한다면 {{jsxref("NaN")}}로 반환합니다.

+ +

설명

+ +

max ()는 Math의 정적 메서드이기 때문에 만든 Math 개체의 메서드가 아닌 항상 Math.max ()로 사용해야합니다. (Math는 생성자가 아닙니다).

+ +

만약 아무 요소도 주어지지 않았다면 {{jsxref("-Infinity")}}로 반환합니다.

+ +

만약 한 개 이상의 요소가 숫자로 변환되지 않는다면 {{jsxref("NaN")}}로 반환됩니다.

+ +

예제

+ +

Math.max()함수 사용하기

+ +
Math.max(10, 20);   //  20
+Math.max(-10, -20); // -10
+Math.max(-10, 20);  //  20
+
+ +

다음 함수는 {{jsxref ( "Function.prototype.apply ()")}}을 사용하여 숫자 배열에서 최대 요소를 찾습니다. getMaxOfArray ([1, 2, 3])는 Math.max (1, 2, 3)와 동일하지만 프로그래밍 방식으로 생성 된 모든 크기의 배열에서 getMaxOfArray ()를 사용할 수 있습니다.

+ +
function getMaxOfArray(numArray) {
+  return Math.max.apply(null, numArray);
+}
+
+ +

{{jsxref("Array.prototype.reduce", "Array.reduce()")}} 이 함수 또한 배열의 각 값을 비교하여 가장 큰 숫자를 얻을 수 있습니다.

+ +
var arr = [1,2,3];
+var max = arr.reduce(function(a, b) {
+    return Math.max(a, b);
+});
+
+ +

또한 {{jsxref("Operators/Spread_operator", "spread operator")}}이 함수를 사용하면 배열의 숫자들 중 가장 큰 숫자를 쉽게 얻을 수 있습니다.

+ +
var arr = [1, 2, 3];
+var max = Math.max(...arr);
+
+ +

표준

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
표준상태비고
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.11', 'Math.max')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.max', 'Math.max')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.max', 'Math.max')}}{{Spec2('ESDraft')}}
+ +

브라우저 호환성

+ + + +

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

+ +

참조

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/min/index.html b/files/ko/web/javascript/reference/global_objects/math/min/index.html new file mode 100644 index 0000000000..7bf84ee57c --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/min/index.html @@ -0,0 +1,103 @@ +--- +title: Math.min() +slug: Web/JavaScript/Reference/Global_Objects/Math/min +translation_of: Web/JavaScript/Reference/Global_Objects/Math/min +--- +
{{JSRef}}
+ +

Math.min() 함수는 주어진 숫자들 중 가장 작은 값을 반환합니다.

+ +

Syntax

+ +
Math.min([value1[, value2[, ...]]])
+ +

Parameters

+ +
+
value1, value2, ...
+
숫자형
+
+ +

Return value

+ +

주어진 숫자들 중 가장 작은 값. 만약 적어도 1개 이상의 인자값이 숫자형으로 변환이 불가능 한 경우 이 함수는 {{jsxref("NaN")}} 를 반환 합니다.

+ +

Description

+ +

min() 함수는 Math 의 정적 메소드 이므로, 사용자가 생성한 Math 객체의 메소드로 호출하는 것이 아닌 항상 Math.min() 으로 호출되어야 합니다. (Math 는 생성자가 아닙니다).

+ +

만약 주어진 인자값이 없을 경우, {{jsxref("Infinity")}} 가 반환됩니다.

+ +

만약 적어도 1개 이상의 인자값이 숫자형으로 변환이 불가능 한 경우, {{jsxref("NaN")}} 가 반환됩니다.

+ +

Examples

+ +

Using Math.min()

+ +

아래 수식은 x 와y 중 작은 값을 찾아 z 에 할당 합니다.     

+ +
var x = 10, y = -20;
+var z = Math.min(x, y);
+
+ +

Clipping a value with Math.min()

+ +

Math.min() 함수는 때때로 값 제한, 즉 항상 기준 보다 작거나 같은 값으로 제한하는 용도로 사용됩니다. 예를 들면,

+ +
var x = f(foo);
+
+if (x > boundary) {
+  x = boundary;
+}
+
+ +

 위 코드는 다음과 같이 쓸 수 있습니다.

+ +
var x = Math.min(f(foo), boundary);
+
+ +

{{jsxref("Math.max()")}} 함수 또한 같은 방식으로 기준보다 크거나 같은 값으로 제한하는 용도로 사용할 수 있습니다.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.12', 'Math.min')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.min', 'Math.min')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.min', 'Math.min')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ + + +

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

+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/pi/index.html b/files/ko/web/javascript/reference/global_objects/math/pi/index.html new file mode 100644 index 0000000000..8223a68df6 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/pi/index.html @@ -0,0 +1,82 @@ +--- +title: Math.PI +slug: Web/JavaScript/Reference/Global_Objects/Math/PI +tags: + - JavaScript + - Math + - Property + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/PI +--- +
{{JSRef}}
+ +

Math.PI 속성은 원의 둘레와 지름의 비율, 약 3.14159의 값을 가집니다.

+ +

Math.PI=π3.14159\mathtt{\mi{Math.PI}} = \pi \approx 3.14159

+ +
{{EmbedInteractiveExample("pages/js/math-pi.html")}}
+ + + +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

PIMath의 정적 속성이므로, 사용자가 생성한 Math 객체의 속성으로 접근할 수 없고 항상 Math.PI를 사용해야 합니다. (Math는 생성자가 아닙니다)

+ +

예제

+ +

Math.PI 사용하기

+ +

다음 함수는 Math.PI를 사용해 주어진 원의 반지름에서 둘레를 계산합니다.

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

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
사양등급주석
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.6', 'Math.PI')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.pi', 'Math.PI')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.pi', 'Math.PI')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/random/index.html b/files/ko/web/javascript/reference/global_objects/math/random/index.html new file mode 100644 index 0000000000..9ce02207de --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/random/index.html @@ -0,0 +1,106 @@ +--- +title: Math.random() +slug: Web/JavaScript/Reference/Global_Objects/Math/random +translation_of: Web/JavaScript/Reference/Global_Objects/Math/random +--- +
{{JSRef}}
+ +

Math.random() 함수는 0 이상 1 미만의 구간에서 근사적으로 균일한(approximately uniform) 부동소숫점 의사난수를 반환하며, 이 값은 사용자가 원하는 범위로 변형할 수 있다. 난수 생성 알고리즘에 사용되는 초기값은 구현체가 선택하며, 사용자가 선택하거나 초기화할 수 없다.

+ +
+

Math.random()은 암호학적으로 안전한 난수를 제공하지 않으므로, 보안과 관련된 어떤 것에도 이 함수를 사용해서는 안 된다. 그 대신 Web Crypto API의 {{domxref("RandomSource.getRandomValues()", "window.crypto.getRandomValues()")}} 메소드를 이용하여야 한다.

+
+ +

문법

+ +
Math.random()
+
+ +

반환 값

+ +

0 이상 1 미만의 부동소숫점 의사 난수.

+ +

예제

+ +

Math.random() 사용

+ +

JavaScript의 수(number)는 가까운 짝수로 반올림되는(round-to-nearest-even behavior) IEEE 754 부동소수점 실수이므로, 아래 함수들(Math.random() 자체에 대한 사항은 제외)에 명시된 범위는 정확하지 않음을 유의하라. 지나치게 큰 범위(253 이상)를 선택할 경우, 매우 드문 경우 원래 포함되어서는 안 될 최댓값이 포함되는 경우가 있다.

+ +

0 이상 1 미만의 난수 생성하기

+ +
function getRandom() {
+  return Math.random();
+}
+
+ +

두 값 사이의 난수 생성하기

+ +

이 예제는 주어진 두 값 사이의 난수를 생성한다. 함수의 반환값은 min보다 크거나 같으며, max보다 작다.

+ +
function getRandomArbitrary(min, max) {
+  return Math.random() * (max - min) + min;
+}
+
+ +

두 값 사이의 정수 난수 생성하기

+ +

이 예제는 주어진 두 값 사이의 정수인 난수를 생성한다. 반환값은 min(단, min이 정수가 아니면 min보다 큰 최소의 정수)보다 크거나 같으며, max보다 작다.

+ +
function getRandomInt(min, max) {
+  min = Math.ceil(min);
+  max = Math.floor(max);
+  return Math.floor(Math.random() * (max - min)) + min; //최댓값은 제외, 최솟값은 포함
+}
+
+ +
+

이 예제에서 Math.round()를 대신 사용하려고 할 수 있으나, 이렇게 하면 난수가 고르게 분포하지 않게 된다.

+
+ +

최댓값을 포함하는 정수 난수 생성하기

+ +

위의getRandomInt() 함수는 최솟값을 포함하지만, 최댓값은 포함하지 않는다. 최솟값과 최댓값을 모두 포함하는 결과가 필요할 경우, 아래의 getRandomIntInclusive() 함수를 사용할 수 있다.

+ +
function getRandomIntInclusive(min, max) {
+  min = Math.ceil(min);
+  max = Math.floor(max);
+  return Math.floor(Math.random() * (max - min + 1)) + min; //최댓값도 포함, 최솟값도 포함
+}
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
명세상태비고
{{SpecName('ES1')}}{{Spec2('ES1')}}초기 정의. JavaScript 1.0 (유닉스 전용) / JavaScript 1.1 (모든 플랫폼).
{{SpecName('ES5.1', '#sec-15.8.2.14', 'Math.random')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-math.random', 'Math.random')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-math.random', 'Math.random')}}{{Spec2('ESDraft')}}
+ +

브라우저 호환성

+ + + +

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

diff --git a/files/ko/web/javascript/reference/global_objects/math/round/index.html b/files/ko/web/javascript/reference/global_objects/math/round/index.html new file mode 100644 index 0000000000..e163c4459e --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/round/index.html @@ -0,0 +1,92 @@ +--- +title: Math.round() +slug: Web/JavaScript/Reference/Global_Objects/Math/round +translation_of: Web/JavaScript/Reference/Global_Objects/Math/round +--- +
{{JSRef}}
+ +

Math.round() 함수는 입력값을 반올림한 수와 가장 가까운 정수 값을 반환합니다.

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

문법

+ +
Math.round(x)
+ +

매개 변수

+ +
+
x
+
+
+ +

반환 값

+ +

입력값을 반올림한 값과 가장 가까운 정수를 의미합니다.

+ +

Description

+ +

If the fractional portion of the argument is greater than 0.5, the argument is rounded to the integer with the next higher absolute value. If it is less than 0.5, the argument is rounded to the integer with the lower absolute value.  If the fractional portion is exactly 0.5, the argument is rounded to the next integer in the direction of +∞.  Note that this differs from many languages' round() functions, which often round this case to the next integer away from zero, instead giving a different result in the case of negative numbers with a fractional part of exactly 0.5.

+ +

Because round() is a static method of Math, you always use it as Math.round(), rather than as a method of a Math object you created (Math has no constructor).

+ +

Examples

+ +
Math.round( 20.49); //  20
+Math.round( 20.5 ); //  21
+Math.round( 42   ); //  42
+Math.round(-20.5 ); // -20
+Math.round(-20.51); // -21
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.15', 'Math.round')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.round', 'Math.round')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.round', 'Math.round')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ + + +

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

+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/sign/index.html b/files/ko/web/javascript/reference/global_objects/math/sign/index.html new file mode 100644 index 0000000000..adb5f15354 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/sign/index.html @@ -0,0 +1,112 @@ +--- +title: Math.sign() +slug: Web/JavaScript/Reference/Global_Objects/Math/sign +tags: + - JavaScript + - Math + - 메소드 + - 참조 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/sign +--- +
{{JSRef}}
+ +

Math.sign() 함수는 어떤 수의 부호를 반환합니다. 이것은 그 수가 양수, 음수 또는 0인지를 나나냅니다.

+ +

문법

+ +
Math.sign(x)
+ +

매개변수

+ +
+
x
+
수치.
+
+ +

반환 값

+ +

주어진 인수의 부호를 나타내는 수치. 인수가 양수, 음수, 양수인 영 또는 음수인 영이면, 이 함수는 1, -1, 0, -0을 각각 반환합니다. 그렇지 않으면, {{jsxref("NaN")}} 이 반환됩니다.

+ +

설명

+ +

sign() 이Math의 정적 메소드이기 때문에 항상 Math.sign()으로 사용합니다. 사용자가 만든  Math 개체의 메소드로 가 아닙니다.   (Math 는 생성자가 아닙니다).

+ +

이 함수는 반환 값이 5 가지이며, 1, -1, 0, -0, NaN 입니다. 각각 "양수", "음수", "양의 영", "음의 영", {{jsxref("NaN")}} 입니다.

+ +

이 함수에 전달된 인수는 묵시적으로 수치 로 변환됩니다.

+ +

예제

+ +

 Math.sign()을 사용하기

+ +
Math.sign(3);     //  1
+Math.sign(-3);    // -1
+Math.sign('-3');  // -1
+Math.sign(0);     //  0
+Math.sign(-0);    // -0
+Math.sign(NaN);   // NaN
+Math.sign('foo'); // NaN
+Math.sign();      // NaN
+
+ +

Polyfill

+ +
if (!Math.sign) {
+  Math.sign = function(x) {
+    // x 가 NaN 이면, 결과는 NaN 입니다.
+    // x 가 -0 이면, 결과는 -0 입니다.
+    // x 가 +0 이면, 결과는 +0 입니다.
+    // x 가 음수이면서 -0 이 아니면, 결과는 -1 입니다.
+    // x 가 양수이면서 +0 이 아니면, 결과는 +1 입니다.
+    return ((x > 0) - (x < 0)) || +x;
+    // A more aesthetical persuado-representation is shown below
+    //
+    // ( (x > 0) ? 0 : 1 )  // if x is negative then negative one
+    //          +           // else (because you cant be both - and +)
+    // ( (x < 0) ? 0 : -1 ) // if x is positive then positive one
+    //         ||           // if x is 0, -0, or NaN, or not a number,
+    //         +x           // Then the result will be x, (or) if x is
+    //                      // not a number, then x converts to number
+  };
+}
+
+ +

위의 polyfill에서는, (x > 0) 또는 (x < 0) 인 수치들을 만드는 데에 어떤 추가의 타입-강제하기도 필요하지 않은 것은  그 수치들을 서로에게서 빼는 것이 불린형에서 수치로의 형 변환을 강요하기 때문입니다.

+ +

규격명세

+ + + + + + + + + + + + + + + + + + + +
규격명세상태코멘트
{{SpecName('ES6', '#sec-math.sign', 'Math.sign')}}{{Spec2('ES6')}}최초의 정의.
{{SpecName('ESDraft', '#sec-math.sign', 'Math.sign')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/sin/index.html b/files/ko/web/javascript/reference/global_objects/math/sin/index.html new file mode 100644 index 0000000000..1978d7f8e8 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/sin/index.html @@ -0,0 +1,97 @@ +--- +title: Math.sin() +slug: Web/JavaScript/Reference/Global_Objects/Math/sin +tags: + - 레퍼런스 + - 메소드 + - 수학 + - 자바스크립트 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/sin +--- +
{{JSRef}}
+ +

 Math.sin() 함수는 숫자의 사인값을 반환합니다.

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

Syntax

+ +
Math.sin(x)
+ +

파라미터

+ +
+
x
+
숫자 (라디안으로 주어짐).
+
+ +

반환 값

+ +

주어진 숫자의 사인 값

+ +

설명

+ +

Math.sin() 메소드는 라디안으로 주어진 각도의 사인 값인 -1과 1 사이의 수를 반환합니다.

+ +

 sin() 은 Math의 스태틱 메소드이기 때문에, Math 오브젝트 의 메소드로 사용하지 말고 항상 Math.sin()로 사용해야합니다.  (Math 는 생성자가 아닙니다).

+ +

+ +

Using Math.sin()

+ +
Math.sin(0);           // 0
+Math.sin(1);           // 0.8414709848078965
+
+Math.sin(Math.PI / 2); // 1
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}최초 정의. JavaScript 1.0. 에서 구현됨
{{SpecName('ES5.1', '#sec-15.8.2.16', 'Math.sin')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sin', 'Math.sin')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sin', 'Math.sin')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

함께 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/sinh/index.html b/files/ko/web/javascript/reference/global_objects/math/sinh/index.html new file mode 100644 index 0000000000..9a3bb3a6ab --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/sinh/index.html @@ -0,0 +1,96 @@ +--- +title: Math.sinh() +slug: Web/JavaScript/Reference/Global_Objects/Math/sinh +translation_of: Web/JavaScript/Reference/Global_Objects/Math/sinh +--- +
{{JSRef}}
+ +

Math.sinh() 함수(쌍곡선 함수)는 사인값을 반환합니다 이 값은 아래와같은 식을통해서 표현할 수 있습니다.{{jsxref("Math.E", "constant e", "", 1)}}:

+ +

Math.sinh(x)=ex-e-x2\mathtt{\operatorname{Math.sinh(x)}} = \frac{e^x - e^{-x}}{2}

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

Syntax

+ +
Math.sinh(x)
+ +

Parameters

+ +
+
x
+
숫자.
+
+ +

Return value

+ +

사인값.

+ +

Description

+ +

sinh() 는 Math 의 정적 함수이기 때문에, 자바스크립트 어디든 Math.sinh() 를 사용할 수 있습니다, 따라서  Math 오브젝트를 생성해서는 안됩니다. (Math 는 constructor(생성자) 가 아닙니다.).

+ +

Examples

+ +

Math.sinh() 사용하기

+ +
Math.sinh(0); // 0
+Math.sinh(1); // 1.1752011936438014
+
+ +

Polyfill

+ +

This can be emulated with the help of the {{jsxref("Math.exp()")}} function:

+ +
Math.sinh = Math.sinh || function(x) {
+  return (Math.exp(x) - Math.exp(-x)) / 2;
+}
+
+ +

or using only one call to the {{jsxref("Math.exp()")}} function:

+ +
Math.sinh = Math.sinh || function(x) {
+  var y = Math.exp(x);
+  return (y - 1 / y) / 2;
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-math.sinh', 'Math.sinh')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-math.sinh', 'Math.sinh')}}{{Spec2('ESDraft')}}
+ +

Browser compatibility

+ + + +

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

+ +

See also

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/sqrt/index.html b/files/ko/web/javascript/reference/global_objects/math/sqrt/index.html new file mode 100644 index 0000000000..f03af42e6f --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/sqrt/index.html @@ -0,0 +1,90 @@ +--- +title: Math.sqrt() +slug: Web/JavaScript/Reference/Global_Objects/Math/sqrt +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

+ +

문법

+ +
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
+
+ +

표준

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
표준상태비고
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.17', 'Math.sqrt')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sqrt', 'Math.sqrt')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sqrt', 'Math.sqrt')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

참조

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/sqrt1_2/index.html b/files/ko/web/javascript/reference/global_objects/math/sqrt1_2/index.html new file mode 100644 index 0000000000..ee347e46eb --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/sqrt1_2/index.html @@ -0,0 +1,59 @@ +--- +title: Math.SQRT1_2 +slug: Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2 +--- +
{{JSRef}}
+ +

Math.SQRT1_2 프로퍼티는 약 0.707의 값을 나타내는 루트 1/2을 나타냅니다:

+ +

Math.SQRT1_2=12=120.707\mathtt{\mi{Math.SQRT1_2}} = \sqrt{\frac{1}{2}} = \frac{1}{\sqrt{2}} \approx 0.707

+ +
{{EmbedInteractiveExample("pages/js/math-sqrt1_2.html", "shorter")}}
+ + + +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

SQRT1_2Math의 정적 프로퍼티이기 때문에, 당신이 생성한 Math 오브젝트의 프로퍼티보다는 항상 Math.SQRT1_2의 형태로 사용합니다 (Math는 컨스트럭터가 아닙니다).

+ +

예시

+ +

Math.SQRT1_2 의 사용

+ +

다음은 루트 1/2를 출력합니다:

+ +
function getRoot1_2() {
+  return Math.SQRT1_2;
+}
+
+getRoot1_2(); // 0.7071067811865476
+
+ +

사양

+ + + + + + + + + + +
사양
{{SpecName('ESDraft', '#sec-math.sqrt1_2', 'Math.SQRT1_2')}}
+ +

브라우저 호환성

+ + + +

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

+ +

같이 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/sqrt2/index.html b/files/ko/web/javascript/reference/global_objects/math/sqrt2/index.html new file mode 100644 index 0000000000..1ad86df55b --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/sqrt2/index.html @@ -0,0 +1,74 @@ +--- +title: Math.SQRT2 +slug: Web/JavaScript/Reference/Global_Objects/Math/SQRT2 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/SQRT2 +--- +
{{JSRef}}
+ +

 Math.SQRT2 는 2의 제곱근을 나타내고 약 1.414 입니다:

+ +

Math.SQRT2=21.414\mathtt{\mi{Math.SQRT2}} = \sqrt{2} \approx 1.414

+ +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

 SQRT2 는  Math의 정적 메서드 이므로 만든 Math 객체의 메서드가 아니라 항상 Math.SQRT2 함수를 사용해야합니다.  (Math는 생성자가 없습니다.)

+ +

예제

+ +

Math.SQRT2

+ +

이 함수는 2의 제곱근을 반환합니다.

+ +
function getRoot2() {
+  return Math.SQRT2;
+}
+
+getRoot2(); // 1.4142135623730951
+
+ +

표준

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
표준상태비고
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.1.8', 'Math.SQRT2')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.sqrt2', 'Math.SQRT2')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.sqrt2', 'Math.SQRT2')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

참조

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/tan/index.html b/files/ko/web/javascript/reference/global_objects/math/tan/index.html new file mode 100644 index 0000000000..64a1468020 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/tan/index.html @@ -0,0 +1,102 @@ +--- +title: Math.tan() +slug: Web/JavaScript/Reference/Global_Objects/Math/tan +tags: + - 레퍼런스 + - 메소드 + - 수학 + - 자바스크립트 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/tan +--- +
{{JSRef}}
+ +

Math.tan() 함수는 탄젠트 값을 반환합니다

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

신텍스

+ +
Math.tan(x)
+ +

Parameters

+ +
+
x
+
라디안 각도 
+
+ +

반환 값

+ +

주어진 수의 탄젠트 값

+ +

설명

+ +

Math.tan() 메소드는 각도의 탄젠트 값을 수로 반환합니다.

+ +

tan()Math의 정적 메서드이므로 사용자가 만든 Math 객체의 메서드가 아닌 항상 Math.tan()으로 사용합니다 (Math 는 생성자가 아닙니다).

+ +

+ +

Using Math.tan()

+ +
Math.tan(1); // 1.5574077246549023
+
+ +

Math.tan()함수는 라디안 값으로 받지만 각도로 작업하는 것이 더 쉽기 때문에 다음 함수는 각도로 값을 받아서 라디안으로 변환하고 탄젠트를 반환합니다.

+ +
function getTanDeg(deg) {
+  var rad = deg * Math.PI/180;
+  return Math.tan(rad);
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.18', 'Math.tan')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.tan', 'Math.tan')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.tan', 'Math.tan')}}{{Spec2('ESDraft')}} 
+ +

브라우저 호환성

+ + + +

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

+ +

함께 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/tanh/index.html b/files/ko/web/javascript/reference/global_objects/math/tanh/index.html new file mode 100644 index 0000000000..97055e165b --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/tanh/index.html @@ -0,0 +1,85 @@ +--- +title: Math.tanh() +slug: Web/JavaScript/Reference/Global_Objects/Math/tanh +tags: + - ECMAScript 2015 + - 레퍼런스 + - 메서드 + - 수학 + - 자바스크립트 +translation_of: Web/JavaScript/Reference/Global_Objects/Math/tanh +--- +
{{JSRef}}
+ +

Math.tanh() 함수는 쌍곡탄젠트 값을 반환합니다. 수식으로는 아래와 같습니다.

+ +

tanhx=sinhxcoshx=ex-e-xex+e-x=e2x-1e2x+1\tanh x = \frac{\sinh x}{\cosh x} = \frac {e^x - e^{-x}} {e^x + e^{-x}} = \frac{e^{2x} - 1}{e^{2x}+1}

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

Syntax

+ +
Math.tanh(x)
+ +

파라미터

+ +
+
x
+
숫자.
+
+ +

반환 값

+ +

주어진 수의 쌍곡탄젠트 값

+ +

설명

+ +

tanh() 은 Math의 정적 메서드이므로 사용자가 만든 Math 객체의 메서드가 아닌 항상 Math.tanh() 으로 사용합니다 (Math 는 생성자가 아닙니다.).

+ +

+ +

Using Math.tanh()

+ +
Math.tanh(0);        // 0
+Math.tanh(Infinity); // 1
+Math.tanh(1);        // 0.7615941559557649
+
+ +

Polyfill

+ +

This can be emulated with the help of the {{jsxref("Math.exp()")}} function:

+ +
Math.tanh = Math.tanh || function(x){
+    var a = Math.exp(+x), b = Math.exp(-x);
+    return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b);
+}
+
+ +

Specifications

+ + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-math.tanh', 'Math.tanh')}}
+ +

브라우저 호환성

+ + + +

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

+ +

함께 보기

+ + diff --git a/files/ko/web/javascript/reference/global_objects/math/trunc/index.html b/files/ko/web/javascript/reference/global_objects/math/trunc/index.html new file mode 100644 index 0000000000..0f63fd1e58 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/math/trunc/index.html @@ -0,0 +1,96 @@ +--- +title: Math.trunc() +slug: Web/JavaScript/Reference/Global_Objects/Math/trunc +translation_of: Web/JavaScript/Reference/Global_Objects/Math/trunc +--- +
{{JSRef}}
+ +

Math.trunc() 함수는 주어진 값의 소수부분을 제거하고 숫자의 정수부분을 반환합니다.

+ +

Syntax

+ +
Math.trunc(x)
+
+ +

Parameters

+ +
+
x
+
숫자형
+
+ +

Return value

+ +

주어진 숫자의 정수부분

+ +

Description

+ +

Math의 유사함수 3개 : {{jsxref("Math.floor()")}}, {{jsxref("Math.ceil()")}} and {{jsxref("Math.round()")}} 와는 다르게, Math.trunc() 함수는 주어진 값이 양수이건 음수이건 상관없이 소수점 이하 우측부분을 제거하는 매우 단순한 동작을 합니다.

+ +

함수인자는 암묵적으로 number형으로 변환되어 메소드에 전달됩니다.

+ +

trunc() 함수는 Math의 정적 메소드이기 때문에 사용자가 생성한 Math 객체의 메소드로 호출하는 것이 아닌 항상 Math.trunc() 형태로 호출해야 합니다. (Math 는 생성자가 아닙니다).

+ +

Examples

+ +

Using Math.trunc()

+ +
Math.trunc(13.37);    // 13
+Math.trunc(42.84);    // 42
+Math.trunc(0.123);    //  0
+Math.trunc(-0.123);   // -0
+Math.trunc('-1.123'); // -1
+Math.trunc(NaN);      // NaN
+Math.trunc('foo');    // NaN
+Math.trunc();         // NaN
+
+ +

Polyfill

+ +
Math.trunc = Math.trunc || function(x) {
+  if (isNaN(x)) {
+    return NaN;
+  }
+  if (x > 0) {
+    return Math.floor(x);
+  }
+  return Math.ceil(x);
+};
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-math.trunc', 'Math.trunc')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-math.trunc', 'Math.trunc')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ + + +

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

+ +

See also

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