--- title: BigInt.asUintN() slug: Web/JavaScript/Reference/Global_Objects/BigInt/asUintN tags: - BigInt - JavaScript - Method - Reference - asUintN - メソッド translation_of: Web/JavaScript/Reference/Global_Objects/BigInt/asUintN ---
BigInt.asUintN 静的メソッドは、 BigInt 値を 0 から 2width-1 までの間の符号なし整数に丸めるために使われます。
BigInt.asUintN(width, bigint);
widthbigintbigint を 2width で割った剰余の値の符号なし整数です。
BigInt.asUintN() メソッドは、64ビットの数値の範囲に収めるのに便利です。
const max = 2n ** 64n - 1n; BigInt.asUintN(64, max); // ↪ 18446744073709551615n BigInt.asUintN(64, max + 1n); // ↪ 0n // オーバーフローするのでゼロになる
| 仕様書 |
|---|
| {{SpecName('ESDraft', '#sec-bigint.asuintn', 'BigInt.asUintN()')}} |
{{Compat("javascript.builtins.BigInt.asUintN")}}