aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/number/tofixed
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/javascript/reference/global_objects/number/tofixed')
-rw-r--r--files/ko/web/javascript/reference/global_objects/number/tofixed/index.html109
1 files changed, 109 insertions, 0 deletions
diff --git a/files/ko/web/javascript/reference/global_objects/number/tofixed/index.html b/files/ko/web/javascript/reference/global_objects/number/tofixed/index.html
new file mode 100644
index 0000000000..cf383f2265
--- /dev/null
+++ b/files/ko/web/javascript/reference/global_objects/number/tofixed/index.html
@@ -0,0 +1,109 @@
+---
+title: Number.prototype.toFixed()
+slug: Web/JavaScript/Reference/Global_Objects/Number/toFixed
+tags:
+ - JavaScript
+ - Method
+ - Number
+ - Prototype
+ - Reference
+translation_of: Web/JavaScript/Reference/Global_Objects/Number/toFixed
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>toFixed()</strong></code> 메서드는 숫자를 고정 소수점 표기법으로 표기해 반환합니다.</p>
+
+<div>{{EmbedInteractiveExample("pages/js/number-tofixed.html")}}</div>
+
+
+
+<h2 id="구문">구문</h2>
+
+<pre class="syntaxbox"><var>numObj</var>.toFixed([<var>digits</var>])</pre>
+
+<h3 id="매개변수">매개변수</h3>
+
+<dl>
+ <dt><code>digits</code> {{optional_inline}}</dt>
+ <dd>소수점 뒤에 나타날 자릿수. 0 이상 20 이하의 값을 사용할 수 있으며, 구현체에 따라 더 넓은 범위의 값을 지원할 수도 있습니다. 값을 지정하지 않으면 0을 사용합니다.</dd>
+</dl>
+
+<h3 id="반환_값">반환 값</h3>
+
+<p>고정 소수점 표기법을 사용하여 나타낸 수.</p>
+
+<h3 id="예외">예외</h3>
+
+<dl>
+ <dt>{{jsxref("RangeError")}}</dt>
+ <dd><code>digits</code>가 너무 작거나 너무 클 때. 값이 0과 100사이의 값이라면 {{jsxref("RangeError")}}를 유발하지 않습니다. 구현체에 따라 더 크거나 작은 값을 지원할 수 있습니다.</dd>
+ <dt>{{jsxref("TypeError")}}</dt>
+ <dd>{{jsxref("Number")}}가 아닌 객체에서 호출한 경우.</dd>
+</dl>
+
+<h2 id="설명">설명</h2>
+
+<p><code>toFixed()</code>는 {{jsxref("Number")}} 객체를 주어진 <code>digits</code> 만큼의 소수점 이하 자리수를 정확하게 갖는 문자열 표현으로 반환합니다. 소수점 이하가 길면 숫자를 반올림하고, 짧아서 부족할 경우 뒤를 0으로 채울 수 있습니다. 메서드를 호출한 숫자의 크기가 1e+21보다 크다면 {{jsxref("Number.prototype.toString()")}}을 호출하여 받은 지수 표기법 결과를 대신 반환합니다.</p>
+
+<h2 id="예제">예제</h2>
+
+<h3 id="toFixed()_사용하기"><code>toFixed()</code> 사용하기</h3>
+
+<pre class="brush: js">var numObj = 12345.6789;
+
+numObj.toFixed(); // Returns '12346': 반올림하며, 소수 부분을 남기지 않습니다.
+numObj.toFixed(1); // Returns '12345.7': 반올림합니다.
+numObj.toFixed(6); // Returns '12345.678900': 빈 공간을 0으로 채웁니다.
+(1.23e+20).toFixed(2); // Returns '123000000000000000000.00'
+(1.23e-10).toFixed(2); // Returns '0.00'
+2.34.toFixed(1); // Returns '2.3'
+2.35.toFixed(1); // Returns '2.4'. 이 경우에는 올림을 합니다.
+-2.34.toFixed(1); // Returns -2.3 (연산자의 적용이 우선이기 때문에, 음수의 경우 문자열로 반환하지 않습니다...)
+(-2.34).toFixed(1); // Returns '-2.3' (...괄호를 사용할 경우 문자열을 반환합니다.)
+</pre>
+
+<h2 id="명세">명세</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES3')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td>Initial definition. Implemented in JavaScript 1.5.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.7.4.5', 'Number.prototype.toFixed')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-number.prototype.tofixed', 'Number.prototype.toFixed')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-number.prototype.tofixed', 'Number.prototype.toFixed')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="브라우저_호환성">브라우저 호환성</h2>
+
+
+
+<p>{{Compat("javascript.builtins.Number.toFixed")}}</p>
+
+<h2 id="참조">참조</h2>
+
+<ul>
+ <li>{{jsxref("Number.prototype.toExponential()")}}</li>
+ <li>{{jsxref("Number.prototype.toPrecision()")}}</li>
+ <li>{{jsxref("Number.prototype.toString()")}}</li>
+</ul>