diff options
author | ache <ache@FreeBSD.org> | 2003-02-17 03:52:35 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2003-02-17 03:52:35 +0000 |
commit | 54d6accf9d69c94d02bb319d998640d79ee83250 (patch) | |
tree | 00af365d9446378d7e5847aa6f4d8a8eee4791d1 /lib/libc/stdlib/rand.c | |
parent | eadbecd88b3b77b4c6e00192f699b8048748ae57 (diff) | |
download | FreeBSD-src-54d6accf9d69c94d02bb319d998640d79ee83250.zip FreeBSD-src-54d6accf9d69c94d02bb319d998640d79ee83250.tar.gz |
Back out "drop first N values" method of removing monotonically increased
seed->first value correlation. It breaks rand_r()... Other possible methods
like shuffling inside aray will breaks rand_r() too, because it assumes
only one word state, i.e. nothing extra can be added after seed assignment
in srand().
BTW, for old formulae seed->first value correlation is not so monotonically
increased as with other Linear Congruential Generators of this type only
becase arithmetic overflow happens. But overflow affects distribution
and lower bits very badly, as many articles says, such type of overflow
not improves PRNG.
So, monotonically increased seed->first value correlation problem remains...
Diffstat (limited to 'lib/libc/stdlib/rand.c')
-rw-r--r-- | lib/libc/stdlib/rand.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 7791218..c412133 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -51,8 +51,6 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #endif /* TEST */ -#define NSHUFF 100 /* to drop part of seed -> 1st value correlation */ - static int do_rand(unsigned long *ctx) { @@ -98,7 +96,7 @@ rand_r(unsigned int *ctx) } -static u_long next = 892053144; /* after srand(1), NSHUFF counted */ +static u_long next = 1; int rand() @@ -110,11 +108,7 @@ void srand(seed) u_int seed; { - int i; - next = seed; - for (i = 0; i < NSHUFF; i++) - (void)rand(); } |