aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/math/trunc
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:17 -0500
commitda78a9e329e272dedb2400b79a3bdeebff387d47 (patch)
treee6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/javascript/reference/global_objects/math/trunc
parent1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff)
downloadtranslated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz
translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2
translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip
initial commit
Diffstat (limited to 'files/ko/web/javascript/reference/global_objects/math/trunc')
-rw-r--r--files/ko/web/javascript/reference/global_objects/math/trunc/index.html96
1 files changed, 96 insertions, 0 deletions
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
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>Math.trunc()</code></strong> 함수는 주어진 값의 소수부분을 제거하고 숫자의 정수부분을 반환합니다.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox">Math.trunc(<var>x</var>)
+</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>x</code></dt>
+ <dd>숫자형</dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>주어진 숫자의 정수부분</p>
+
+<h2 id="Description">Description</h2>
+
+<p>Math의 유사함수 3개 : {{jsxref("Math.floor()")}}, {{jsxref("Math.ceil()")}} and {{jsxref("Math.round()")}} 와는 다르게, <code>Math.trunc()</code> 함수는 주어진 값이 양수이건 음수이건 상관없이 소수점 이하 우측부분을 제거하는 매우 단순한 동작을 합니다.</p>
+
+<p>함수인자는 암묵적으로 number형으로 변환되어 메소드에 전달됩니다.</p>
+
+<p><code>trunc()</code> 함수는 Math의 정적 메소드이기 때문에 사용자가 생성한 <code>Math</code> 객체의 메소드로 호출하는 것이 아닌 항상 <code>Math.trunc()</code> 형태로 호출해야 합니다. (<code>Math</code> 는 생성자가 아닙니다).</p>
+
+<h2 id="Examples">Examples</h2>
+
+<h3 id="Using_Math.trunc()">Using <code>Math.trunc()</code></h3>
+
+<pre class="brush: js">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
+</pre>
+
+<h2 id="Polyfill">Polyfill</h2>
+
+<pre class="brush: js">Math.trunc = Math.trunc || function(x) {
+ if (isNaN(x)) {
+ return NaN;
+ }
+ if (x &gt; 0) {
+ return Math.floor(x);
+ }
+ return Math.ceil(x);
+};</pre>
+
+<h2 id="Specifications">Specifications</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('ES2015', '#sec-math.trunc', 'Math.trunc')}}</td>
+ <td>{{Spec2('ES2015')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-math.trunc', 'Math.trunc')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+
+<p>{{Compat("javascript.builtins.Math.trunc")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{jsxref("Math.abs()")}}</li>
+ <li>{{jsxref("Math.ceil()")}}</li>
+ <li>{{jsxref("Math.floor()")}}</li>
+ <li>{{jsxref("Math.round()")}}</li>
+ <li>{{jsxref("Math.sign()")}}</li>
+</ul>