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 [-0x20000000000000, 0x20000000000000] 11 : */ 12 0 : export function int53Full(engine: Engine): number { 13 0 : while (true) { 14 0 : const high = engine.next() | 0; 15 0 : if (high & 0x400000) { 16 0 : if ((high & 0x7fffff) === 0x400000 && (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 ( 22 0 : (high & UINT21_MAX) * UINT32_SIZE + 23 0 : low + 24 0 : (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0) 25 0 : ); 26 0 : } 27 0 : } 28 0 : }