From 3193ffd9cce5d1fa95b081e5fcd8d31295015d87 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 13 Mar 2013 14:41:04 +0900 Subject: [PATCH] Better (-1..1) random numbers. Now the distribution should be more even as the rng doesn't affect the exponent. --- libs/util/test/test-bary.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/util/test/test-bary.c b/libs/util/test/test-bary.c index 39b3cf50d..fdb712642 100644 --- a/libs/util/test/test-bary.c +++ b/libs/util/test/test-bary.c @@ -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