Line data Source code
1 : import { Engine } from "../types.ts"; 2 1 : import { 3 1 : SMALLEST_UNSAFE_INTEGER, 4 1 : UINT21_MAX, 5 1 : UINT21_SIZE, 6 1 : UINT32_SIZE 7 1 : } from "../utils/constants.ts"; 8 : 9 : /** 10 : * Returns a value within [0, 0x20000000000000] 11 : */ 12 0 : export function uint53Full(engine: Engine): number { 13 0 : while (true) { 14 0 : const high = engine.next() | 0; 15 0 : if (high & UINT21_SIZE) { 16 0 : if ((high & UINT21_MAX) === 0 && (engine.next() | 0) === 0) { 17 0 : return SMALLEST_UNSAFE_INTEGER; 18 0 : } 19 0 : } else { 20 0 : const low = engine.next() >>> 0; 21 0 : return (high & UINT21_MAX) * UINT32_SIZE + low; 22 0 : } 23 0 : } 24 0 : }