The following snippet of code is taken from a Pseudo-random number generator (written in ActionScript 3):
public function random():Number {
_currentSeed = (_currentSeed * 16807) % 2147483647);
return (_currentSeed/0x7FFFFFFF) + 0.000000000233;
}
The first line of the code is easy to understand, it's a standard linear congruential generator, with the multiplier being 16807
. The first part of the second line converts the resulting integer to a float roughly between 0
and 1
.
However, what is the purpose of that last part of the second line, + 0.000000000233
? Is it necessary in such an RNG, or does it serve a different purpose?