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, 0x1fffffffffffff] 11 : */ 12 0 : export function int53(engine: Engine): number { 13 0 : const high = engine.next() | 0; 14 0 : const low = engine.next() >>> 0; 15 0 : return ( 16 0 : (high & UINT21_MAX) * UINT32_SIZE + 17 0 : low + 18 0 : (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0) 19 0 : ); 20 0 : }