aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/javascript/reference/global_objects/bigint/asuintn/index.html
blob: 87e7d50cd9f57c773d49a3f4fc446d4c4abf048b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: BigInt.asUintN()
slug: Web/JavaScript/Reference/Global_Objects/BigInt/asUintN
tags:
  - BigInt
  - JavaScript
  - Довідка
  - метод
translation_of: Web/JavaScript/Reference/Global_Objects/BigInt/asUintN
---
<div>{{JSRef}}</div>

<p>Статичний метод <strong><code>BigInt.asUintN</code></strong> використовується для обертання значення BigInt до цілого беззнакового числа у діапазоні між 0 та 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="Синтаксис">Синтаксис</h2>

<pre class="syntaxbox notranslate">BigInt.asUintN(<var>width</var>, <var>bigint</var>);</pre>

<h3 id="Параметри">Параметри</h3>

<dl>
 <dt><code><var>width</var></code></dt>
 <dd>Кількість бітів, доступних для розміру цілого числа.</dd>
 <dt><code><var>bigint</var></code></dt>
 <dd>Ціле число, яке треба затиснути, щоб вмістити у надані біти.</dd>
</dl>

<h3 id="Повертає">Повертає</h3>

<p>Значення <code><var>bigint</var></code> за модулем 2<sup><code><var>width</var></code></sup> у вигляді цілого беззнакового числа.</p>

<h2 id="Приклади">Приклади</h2>

<h3 id="Щоб_залишатись_у_64-бітному_діапазоні">Щоб залишатись у 64-бітному діапазоні</h3>

<p>Метод <code>BigInt.asUintN()</code> може бути корисним, якщо потрібно залишатись у межах 64-бітної арифметики.</p>

<pre class="brush: js notranslate">const max = 2n ** 64n - 1n;

BigInt.asUintN(64, max);
// ↪ 18446744073709551615n

BigInt.asUintN(64, max + 1n);
// ↪ 0n
// нуль, через переповнення</pre>

<h2 id="Специфікації">Специфікації</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Специфікація</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-bigint.asuintn', 'BigInt.asUintN()')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>



<p>{{Compat("javascript.builtins.BigInt.asUintN")}}</p>

<h2 id="Див._також">Див. також</h2>

<ul>
 <li>{{JSxRef("BigInt")}}</li>
 <li>{{JSxRef("BigInt.asIntN()")}}</li>
</ul>