aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/bigint/asuintn/index.html
blob: 5331dbae119bd89ae102d4aa3da1ccf4101f80a2 (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
---
title: BigInt.asUintN()
slug: Web/JavaScript/Reference/Global_Objects/BigInt/asUintN
tags:
  - BigInt
  - Experimental
  - JavaScript
  - Méthode
  - Reference
translation_of: Web/JavaScript/Reference/Global_Objects/BigInt/asUintN
original_slug: Web/JavaScript/Reference/Objets_globaux/BigInt/asUintN
---
<p>{{JSRef}}</p>

<p>La méthode statique <strong><code>BigInt.asUintN()</code></strong> permet d'écréter un <code>BigInt</code> pour ramener sa valeur sur un entier non-signé entre 0 et 2^(largeur)-1.</p>

<div>{{EmbedInteractiveExample("pages/js/bigint-asuintn.html")}}</div>

<h2 id="Syntaxe">Syntaxe</h2>

<pre class="syntaxbox">var <var>résultat</var> = BigInt.asUintN(<var>largeur</var>, <var>bigint</var>);</pre>

<h3 id="Paramètres">Paramètres</h3>

<dl>
 <dt><code>largeur</code></dt>
 <dd>Le nombre de bits disponible pour stocker l'entier.</dd>
 <dt><code>bigint</code></dt>
 <dd>L'entier qu'on souhaite stocker sur le nombre de bits indiqués.</dd>
</dl>

<h3 id="Valeur_de_retour">Valeur de retour</h3>

<p>La valeur de <code>bigint</code> modulo 2^<code>largeur</code> comme un entier non signé.</p>

<h2 id="Exemples">Exemples</h2>

<p>La méthode <code>BigInt.asUintN()</code> peut s'avérer utile pour rester dans une arithmétique exprimée sur 64 bits .</p>

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

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

BigInt.asUintN(64, max + 1n);
// ↪ 0n
// zéro en raison du dépassement</pre>

<h2 id="Spécifications">Spécifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Spécification</th>
   <th scope="col">État</th>
  </tr>
  <tr>
   <td><a href="https://tc39.github.io/proposal-bigint/#sec-bigint.asuintn">Proposition pour BigInt</a></td>
   <td>Proposition de niveau 3</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>

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

<h2 id="Voir_aussi">Voir aussi</h2>

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