src/util/Util.js
/**
 * Generates random integers a-la NumPy's in the "half-open" interval [min, max). In other words, from min inclusive to max exclusive. When max is undefined, as is the case by default, results are chosen from [0, min). An error is thrown if max is less than min.
 *
 * @name module:util.randint
 * @function
 * @public
 * @param {number} [min = 0] - lowest integer to be drawn, or highest plus one if max is undefined (default)
 * @param {number} max - one above the largest integer to be drawn
 * @returns {number} a random integer in the requested range (signed)
 */
Generates random integers a-la NumPy's in the "half-open" interval [min, max). In other words, from min inclusive to max exclusive. When max is undefined, as is the case by default, results are chosen from [0, min). An error is thrown if max is less than min.
Generates random integers a - la NumPy ' s in the " half - open " interval [ min max ) . In other words from min inclusive to max exclusive . When max is undefined as is the case by default results are chosen from [ 0 min ) . An error is thrown if max is less than min .
function randint(min = 0, max)
{
	let lo = min;
	let hi = max;
	if (typeof max === "undefined")
	{
		hi = lo;
		lo = 0;
	}
	if (hi < lo)
	{
		throw {
			origin: "util.randint",
			context: "when generating a random integer",
			error: "min should be <= max",
		};
	}
	return Math.floor(Math.random() * (hi - lo)) + lo;
}
function randint ( min = 0 , max ) { let lo = min ; let hi = max ; if ( typeof max === "undefined" ) { hi = lo ; lo = 0 ; } if ( hi < lo ) { throw { origin : "util.randint" , context : "when generating a random integer" , error : "min should be <= max" , } ; } return Math . floor ( Math . random ( ) * ( hi - lo ) ) + lo ; }
Generates random integers a-la NumPy's in the "half-open" interval [min, max).
Generates random integers a - la NumPy ' s in the " half - open " interval [ min max ) .