Standard built-ins

BigInt.asIntN()

Try the free JavaScript compiler

Reduces a BigInt modulo 2^bits and interprets the result as a signed two-complement integer of that width. bits uses index conversion; an invalid width throws RangeError. Width zero yields 0n.

Formal Syntax & Structure

javascript syntaxjavascript
BigInt.asIntN(bits, value)

Parameters & Attributes

NameTypeDescription
bitsnumberNonnegative bit width after index conversion.
valuebigintInput converted using ToBigInt.

Return Value

bigint

Signed width-limited result.

Working Example

Example Snippetjavascript
console.log(String(BigInt.asIntN(8,255n)));
JavaScript Reference