diff options
Diffstat (limited to 'files/tr/web/javascript/reference/global_objects/math/sign/index.html')
-rw-r--r-- | files/tr/web/javascript/reference/global_objects/math/sign/index.html | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/files/tr/web/javascript/reference/global_objects/math/sign/index.html b/files/tr/web/javascript/reference/global_objects/math/sign/index.html deleted file mode 100644 index cbed44a438..0000000000 --- a/files/tr/web/javascript/reference/global_objects/math/sign/index.html +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: Math.sign() -slug: Web/JavaScript/Reference/Global_Objects/Math/sign -translation_of: Web/JavaScript/Reference/Global_Objects/Math/sign ---- -<div>{{JSRef}}</div> - -<div><code><strong>Math.sign()</strong></code> fonksiyonu, parametre olarak aldığı sayının negatif (-1) veya pozitif (1) olduğu bilgisini döndürür. Parametre olarak 0 gönderilirse, +/- 0 döndürür. Sayı pozitifse ayrıca + işareti döndürülmez.</div> - -<div></div> - -<div>{{EmbedInteractiveExample("pages/js/math-sign.html")}}</div> - -<div class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</div> - -<h2 id="Syntax">Syntax</h2> - -<pre class="syntaxbox">Math.sign(<var>x</var>)</pre> - -<h3 id="Parameters">Parameters</h3> - -<dl> - <dt><code><var>x</var></code></dt> - <dd>A number. If this argument is not a <code>number</code>, it is implicitly converted to one.</dd> -</dl> - -<h3 id="Return_value">Return value</h3> - -<p>A number representing the sign of the given argument:</p> - -<ul> - <li>If the argument is positive, returns <code>1</code>.</li> - <li>If the argument is negative, returns <code>-1</code>.</li> - <li>If the argument is positive zero, returns <code>0</code>.</li> - <li>If the argument is negative zero, returns <code>-0</code>.</li> - <li>Otherwise, {{jsxref("NaN")}} is returned.</li> -</ul> - -<h2 id="Description">Description</h2> - -<p>Because <code>sign()</code> is a static method of <code>Math</code>, you always use it as <code>Math.sign()</code>, rather than as a method of a <code>Math</code> object you created (<code>Math</code> is not a constructor).</p> - -<h2 id="Polyfill">Polyfill</h2> - -<pre class="brush: js">if (!Math.sign) { - Math.sign = function(x) { - // If x is NaN, the result is NaN. - // If x is -0, the result is -0. - // If x is +0, the result is +0. - // If x is negative and not -0, the result is -1. - // If x is positive and not +0, the result is +1. - return ((x > 0) - (x < 0)) || +x; - // A more aesthetic pseudo-representation: - // - // ( (x > 0) ? 1 : 0 ) // if x is positive, then positive one - // + // else (because you can't be both - and +) - // ( (x < 0) ? -1 : 0 ) // if x is negative, then negative 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 - }; -} -</pre> - -<p>In the above polyfill, no extra type-coercing is needed to make <code>(x > 0)</code> or <code>(x < 0)</code> numbers because subtracting them from each other forces a type conversion from booleans to numbers.</p> - -<h2 id="Examples">Examples</h2> - -<h3 id="Using_Math.sign">Using <code>Math.sign()</code></h3> - -<pre class="brush: js">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 -</pre> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('ESDraft', '#sec-math.sign', 'Math.sign')}}</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - -<div 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 class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</div> - -<p>{{Compat("javascript.builtins.Math.sign")}}</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.trunc()")}}</li> -</ul> |