Better (-1..1) random numbers.

Now the distribution should be more even as the rng doesn't affect the
exponent.
This commit is contained in:
Bill Currie 2013-03-13 14:41:04 +09:00
parent b6d4766201
commit 3193ffd9cc

View file

@ -58,9 +58,11 @@ rnd (mtstate_t *mt)
} uf;
do {
uf.u = mtwist_rand (mt) & 0x3fffffff;
uf.u = mtwist_rand (mt) & 0x007fffff;
} while (!uf.u);
return uf.f - 1.0;
uf.u |= 0x40000000;
return uf.f - 3.0;
}
int