[PATCH] rand.c updates from FreeBSD RELENG_5
Joerg Sonnenberger
joerg at britannica.bec.de
Wed May 12 05:20:16 PDT 2004
On Wed, May 12, 2004 at 06:11:21AM -0500, William M. Grim wrote:
> I have included the patch, but to see what I mean about the current
> rand(3) not being great, try this code (yes, I know, the seeding could
> have been done better):
>
[snip]
> cs = rand() % 2;
[snip]
In any good book about the rand() PRNG and in random(3) is a note that the
lower bits have a very low entropy. E.g. chance the code to
cs = (rand() >> 8) % 2;
provides much better results.
Joerg
More information about the Submit
mailing list