From b3e49da323b53d5300c3c9e918d8f9d83cc372a8 Mon Sep 17 00:00:00 2001 From: louis220 <46963394+louis220@users.noreply.github.com> Date: Tue, 3 Aug 2021 15:09:57 +0900 Subject: [log2]폴리 필 추가 (#1264) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: hochan Lee --- .../reference/global_objects/math/log2/index.html | 148 +++++++++++++-------- 1 file changed, 95 insertions(+), 53 deletions(-) (limited to 'files/ko/web/javascript/reference') 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 index 88e58db3d0..86d4f9f3db 100644 --- a/files/ko/web/javascript/reference/global_objects/math/log2/index.html +++ b/files/ko/web/javascript/reference/global_objects/math/log2/index.html @@ -2,33 +2,82 @@ title: Math.log2() slug: Web/JavaScript/Reference/Global_Objects/Math/log2 translation_of: Web/JavaScript/Reference/Global_Objects/Math/log2 +tags: + - ECMAScript 2015 + - JavaScript + - Math + - Method + - Reference + - Polyfill +browser-compat: javascript.builtins.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

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

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

문법

Math.log2(x)
-

매개변수

+

매개변수

-
x
-
숫자.
+
x
+
숫자.
-

반환 값

+

반환 값

-

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

+

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

-

설명

+

설명

-

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

+

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

-

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

+

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

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

@@ -36,11 +85,25 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/log2

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

-

예제

+

폴리 필

+

+ 폴리 필은 Math.log2함수를 모방합니다. 일부 입력(예: 1 << + 29)에 대해 부정확한 값을 반환할 수 있습니다. 만약 비트마스크로 작업할 경우 + {{jsxref("Math.round()")}} 로 감싸주어야 합니다. +

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

예제

Math.log2()

-
Math.log2(3);    // 1.584962500721156
+
+Math.log2(3);    // 1.584962500721156
 Math.log2(2);    // 1
 Math.log2(1);    // 0
 Math.log2(0);    // -Infinity
@@ -48,47 +111,26 @@ 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.

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

브라우저 호환성

+ +

{{Compat}}

-

표준

- - - - - - - - - - - - - - - - - - - -
표준상태비고
{{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")}}

- -

참조

+

같이 보기

-- cgit v1.2.3-54-g00ecf