BigInt Math S1
- Stage: Stage 1
- Status: Active
- ECMAScript edition: —
- Synchronized: Aug 28, 2026
- 中文译文 · Source repository
This proposal adds BigInt math functions to address the lack of integer-only math operations in JavaScript, supplementing the existing Math object which only supports floating-point Numbers. It proposes seven static functions on the BigInt namespace, such as BigInt.abs and BigInt.sqrt, which accept only BigInts and return BigInts, with truncating behavior for sqrt and cbrt.
The README below comes from the upstream repository and may contain outdated stage or status metadata. Use the proposal details above as the current source of truth.
BigInt Math for JavaScript
ECMAScript Stage 1 Proposal
J. S. Choi, 2021–2025
- Specification
- Babel plugin: Not yet
Description
(A formal draft specification is available.)
BigInts are important for a myriad of
mathematical, financial, scientific, and timing applications
(such as in the Node.js process.hrtime.bigint API),
and they have been therefore a valuable addition to JavaScript
since their standardization in ES 2021.
Several built-in Math functions
would make sense with BigInts,
yet JavaScript still does not have not support them.
They only support regular floating-point JavaScript Numbers.
- This proposal adds the following functions
to the BigInt object acting as a namespace:
BigInt.absBigInt.signBigInt.sqrt*BigInt.cbrt*BigInt.powBigInt.min†BigInt.max†
- All of these functions return BigInts.
- None of these functions accept any arguments other than BigInts.
- *
sqrtandcbrttruncate the result toward 0 into a BigInt. - †
minandmaxrequire at least one argument.
Philosophy
This proposal balances performance with precedent.
- Monomorphic functions are much easier for engines to optimize than polymorphic functions.
- BigInts and Numbers are not semantically interchangeable. Developers should be aware when using BigInt versus Numbers to avoid errors.
- It is ergonomically desirable for BigInt math functions’ API to be as consistent with existing number functions in Math as possible.
- Numbers and BigInts are primitives,
so math functions should be static functions like
BigInt.abs(v), rather than prototype methods likev.abs().- This matches the precedent of
BigInt.asIntNandBigInt.asUintN. - This is unlike the proposed Decimal128s. Decimal128s will be objects and thus should use prototype methods.)
- This matches the precedent of
Vision
This initial proposal adds only a few first BigInt methods.
The vision is that this proposal would open up the way
to new proposals for new BigInt math functions, like:
BigInt.gcd(v): Greatest common divisor (GCD)BigInt.popCount(v): Population countBigInt.bitLength(v): Bit length, i.e., truncating log2BigInt.modPow(v, exponent, modulus): Modular exponentiationBigInt.modInverse(v, modulus): Modular multiplicative inverseBigInt.fromString(value, radix): Base-n string parsingBigInt.toByteArray(v, endian): Conversion to byte arrayBigInt.fromByteArray(bytes, endian): Conversion from byte array
Some of these may also be appropriate for ordinary integer Numbers.
Excluded Math
Math functions that would not make sense with BigInts
are excluded from this proposal. These include: