random method
Implementation
double random(double high) {
// avoid an infinite loop when 0 or NaN are passed in
if (high == 0 || high != high) {
return 0;
}
if (internalRandom == null) {
internalRandom = math.Random();
}
// for some reason (rounding error?) Math.random() * 3
// can sometimes return '3' (once in ~30 million tries)
// so a check was added to avoid the inclusion of 'howbig'
double value = 0;
do {
value = internalRandom!.nextDouble() * high;
} while (value == high);
return value;
}