Small fixes
A selection of 80 fixes from 174 pull requests.
36.The excluded endpoint
A draw below 1 can still round to 20 in a [10, 20) range. If that happens, return the upper bound’s nearest representable predecessor.
123456789101112131415161718
/** @internal */export const nextBetween = (min: number, max: number, draw: number): number => { const value = draw * (max - min) + min if (value !== max || min >= max || !Number.isFinite(max)) { return value } // Rounding can reach the excluded endpoint even for a draw below 1. // Return its immediate predecessor, which is at least min for finite min < max. if (max === 0) { return -Number.MIN_VALUE } const view = new DataView(new ArrayBuffer(8)) view.setFloat64(0, max) const bits = view.getBigUint64(0) view.setBigUint64(0, max > 0 ? bits - BigInt(1) : bits + BigInt(1)) return view.getFloat64(0)}