BigInt.asUintN
static method is used to wrap a BigInt value to an unsigned integer between 0 and 2
width
-1.
BigInt.asUintN(width, bigint);
width
The amount of bits available for the integer size.
bigint
The integer to clamp to fit into the supplied bits.
值
bigint
modulo 2
width
as an unsigned integer.
BigInt.asUintN()
method can be useful to stay in the range of 64-bit arithmetic.
const max = 2n ** 64n - 1n; BigInt.asUintN(64, max); // ↪ 18446744073709551615n BigInt.asUintN(64, max + 1n); // ↪ 0n // zero because of overflow
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'BigInt.asUintN()' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
asUintN
|
Chrome 67 | Edge 79 | Firefox 68 | IE No | Opera 54 | Safari No | WebView Android 67 | Chrome Android 67 | Firefox Android 68 | Opera Android 48 | Safari iOS No | Samsung Internet Android 9.0 | nodejs 10.4.0 |
完整支持
不支持
BigInt
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()