bigint

Contents

bigint#

Arbitrary-precision integer; literal suffix n. Cannot mix with number without an explicit conversion.

A bigint literal.

const big = 9007199254740993n;

Arithmetic stays inside the bigint domain.

big + 1n;             // 9007199254740994n

Mixing with number is a TypeError.

big + 1;              // TypeError: cannot mix BigInt and number

Convert to number explicitly; precision may be lost.

Number(big);          // 9007199254740992 (lossy)

References#

  • number for IEEE 754 doubles.

  • Casting for BigInt(n) conversion rules.