Skip to content

Instantly share code, notes, and snippets.

View UInt64.js
// Input may exceed JS 53-bit int limits
// So we need a small UInt64 implementation
// Yeah I know it can be improved with some bitwise ops, whatever.
const UInt32Max = 2**32;
export class UInt64{
constructor(hi, lo, rem) {
if (lo !== undefined) {
// Proper overflow/unsignedness of both 32bit components.
if (+lo >= UInt32Max) {
hi += Math.floor(lo / UInt32Max);