Files
scriptc/tests/corpus/2901-bigint-core.ts
Chris Tate 1600935411 Add static-native BigInt support (#346)
* feat: add static BigInt support

* fix: prevent BigInt width overflow on WASI

* fix: harden BigInt formatting sizes

* test: record BigInt WASI parity baseline
2026-09-18 00:21:12 -05:00

15 lines
854 B
TypeScript

const huge = 1234567890123456789012345678901234567890n;
const other = 98765432109876543210987654321n;
console.log("literal", huge);
console.log("arith", huge + other, huge - other, 123456789n * 987654321n);
console.log("divmod", -100n / 9n, -100n % 9n);
console.log("pow", 3n ** 40n);
console.log("bits", (-12345678901234567890n & 0xffffffffffffffffn).toString(16));
console.log("shift", 1n << 100n, -9n >> 2n, 8n << -1n);
console.log("compare", huge > other, huge === BigInt("1234567890123456789012345678901234567890"));
console.log("mixed", 2n < 2.5, 2.5 > 2n, 2n < NaN, -3n < -2.5, 10n < Infinity);
console.log("convert", BigInt(9007199254740992), BigInt(true), Number(9007199254740993n));
console.log("width", BigInt.asUintN(8, -1n), BigInt.asIntN(8, 255n));
console.log("text", `${huge}`, huge.toString(36), typeof huge, Boolean(0n), Boolean(1n));