Files
scriptc/tests/corpus/2902-bigint-bytes.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

16 lines
652 B
TypeScript

const b = Buffer.alloc(24);
console.log("offsets", b.writeBigUInt64BE(0xffffffffffffffffn), b.writeBigInt64LE(-2n, 8));
console.log("reads", b.readBigUInt64BE(), b.readBigUint64BE(), b.readBigInt64LE(8));
b.writeBigUint64LE(0x0123456789abcdefn, 16);
console.log("hex", b.toString("hex"), b.readBigUInt64LE(16).toString(16));
const view = new DataView(b.buffer, 4, 16);
view.setBigUint64(0, 0xfedcba9876543210n);
view.setBigInt64(8, -1234567890123456789n, true);
console.log("view", view.getBigUint64(0).toString(16), view.getBigInt64(8, true));
view.setBigInt64(0, (1n << 80n) + 5n);
console.log("wrap", view.getBigInt64(0), view.getBigUint64(0));