August 2018
Beginner
334 pages
10h 19m
English
We should always strive for efficiency. That's why there's another way to deliver a similar result. In this case, we could implement a new member function based on the solution offered by Rabin et al. (refer to the following See also section), as shown in the following code:
public static ulong seed = 61829450;
public static float Range()
{
double sum = 0;
for (int i = 0; i < 3; i++)
{
ulong holdseed = seed;
seed ^= seed << 13;
seed ^= seed >> 17;
seed ^= seed << 5;
long r = (long)(holdseed * seed);
sum += r * (1.0 / 0x7FFFFFFFFFFFFFFF);
}
return (float)sum;
}
Read now
Unlock full access