API:RNG::next
From Spherical
RNG::next() generates a pseudorandom floating-point number between 0.0 and 1.0 (exclusive).
Usage
number = rng_object.next();
Example
/* * Shuffle a list of numbers (Fisher-Yates) */ let numbers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] let rnGen = new RNG(); for (let i = numbers.length - 1; i > 0; --i) { let j = Math.floor(rnGen.next() * (i + 1)); // integer, [0,i] let orig_i = numbers[i]; numbers[i] = numbers[j]; numbers[j] = orig_i; }