aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/javascript/reference/global_objects/bigint/asuintn
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
commit074785cea106179cb3305637055ab0a009ca74f2 (patch)
treee6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/ru/web/javascript/reference/global_objects/bigint/asuintn
parentda78a9e329e272dedb2400b79a3bdeebff387d47 (diff)
downloadtranslated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz
translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2
translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip
initial commit
Diffstat (limited to 'files/ru/web/javascript/reference/global_objects/bigint/asuintn')
-rw-r--r--files/ru/web/javascript/reference/global_objects/bigint/asuintn/index.html72
1 files changed, 72 insertions, 0 deletions
diff --git a/files/ru/web/javascript/reference/global_objects/bigint/asuintn/index.html b/files/ru/web/javascript/reference/global_objects/bigint/asuintn/index.html
new file mode 100644
index 0000000000..6f3c09ba56
--- /dev/null
+++ b/files/ru/web/javascript/reference/global_objects/bigint/asuintn/index.html
@@ -0,0 +1,72 @@
+---
+title: BigInt.asUintN()
+slug: Web/JavaScript/Reference/Global_Objects/BigInt/asUintN
+translation_of: Web/JavaScript/Reference/Global_Objects/BigInt/asUintN
+---
+<div>{{JSRef}}</div>
+
+<p>The <strong><code>BigInt.asUintN</code></strong> static method is used to wrap a BigInt value to an unsigned integer between 0 and 2<sup>width</sup>-1.</p>
+
+<div>{{EmbedInteractiveExample("pages/js/bigint-asuintn.html", "taller")}}</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 notranslate">BigInt.asUintN(<var>width</var>, <var>bigint</var>);</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code><var>width</var></code></dt>
+ <dd>The amount of bits available for the integer size.</dd>
+ <dt><code><var>bigint</var></code></dt>
+ <dd>The integer to clamp to fit into the supplied bits.</dd>
+</dl>
+
+<h3 id="Returns">Returns</h3>
+
+<p>The value of <code><var>bigint</var></code> modulo 2<sup><code><var>width</var></code></sup> as an unsigned integer.</p>
+
+<h2 id="Examples">Examples</h2>
+
+<h3 id="Staying_in_64-bit_ranges">Staying in 64-bit ranges</h3>
+
+<p>The <code>BigInt.asUintN()</code> method can be useful to stay in the range of 64-bit arithmetic.</p>
+
+<pre class="brush: js notranslate">const max = 2n ** 64n - 1n;
+
+BigInt.asUintN(64, max);
+// ↪ 18446744073709551615n
+
+BigInt.asUintN(64, max + 1n);
+// ↪ 0n
+// zero because of overflow</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-bigint.asuintn', 'BigInt.asUintN()')}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("javascript.builtins.BigInt.asUintN")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{JSxRef("BigInt")}}</li>
+ <li>{{JSxRef("BigInt.asIntN()")}}</li>
+</ul>