Date: Mon, 07 Apr 2003 15:12:26 +0100 From: Colin Percival <colin.percival@wadham.ox.ac.uk> To: Eric Timme <timothy@voidnet.com> Cc: freebsd-stable@freebsd.org Subject: Re: 4-stable and C rand()? Message-ID: <5.0.2.1.1.20030407150811.01dcf008@popserver.sfu.ca> In-Reply-To: <200304070901.20557.timothy@voidnet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
At 09:01 07/04/2003 -0500, Eric Timme wrote:
>No matter how many times I run this it seems to alternate between generating
>two different but non-unique sets of values, depending on whether time(0) is
>even or odd..and I can't understand why (values at the end of this message).
>[...] I just want to know
>what I'm doing wrong, and why I can't do this on my FreeBSD machine =\
$ man rand
RAND(3) FreeBSD Library Functions Manual RAND(3)
NAME
rand, srand, rand_r - bad random number generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^
You're not doing anything wrong; rand(3) is explicitly defined to be a bad random number generator. If you want a slightly better random number generator for non-cryptographic purposes, you could use random(3).
Colin Percival
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5.0.2.1.1.20030407150811.01dcf008>
