This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |