JS Built-ins
BigIntasIntNintermediate

BigInt.asIntN() β€” overflow to negative

πŸ“– Usage Example
BigInt.asIntN(8, 255n)  // β†’ -1n (wraps as signed 8-bit)

BigInt.asIntN() wraps a BigInt to fit within a signed N-bit integer.

BigInt.asIntN(width, bigint)

Wraps a BigInt to a signed N-bit integer. BigInt.asIntN(8, 255n) overflows signed 8-bit to -1n.

Challenge: Verify this overflow.

πŸ’‘ Hints (1)
  • β€’ Signed 8-bit max is 127; 255 wraps to -1 in two's complement.