Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Apr 2003 15:58:39 -0700
From:      Kris Kennaway <kris@obsecurity.org>
To:        David Malone <dwmalone@maths.tcd.ie>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: 4-stable and C rand()?
Message-ID:  <20030407225839.GA60254@rot13.obsecurity.org>
In-Reply-To: <20030407141603.GA96746@walton.maths.tcd.ie>
References:  <200304070901.20557.timothy@voidnet.com> <20030407141603.GA96746@walton.maths.tcd.ie>

next in thread | previous in thread | raw e-mail | index | archive | help

--5vNYLRcllDrimb99
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Apr 07, 2003 at 03:16:03PM +0100, David Malone wrote:

> Rather than use rand()%32 you might want to use something like
> (rand()+RAND_MAX/64)/(RAND_MAX/32) - using the high order bits means
> that you are not effectively reducing the side of the state space.

Or use a better PRNG like arc4random().

Kris

--5vNYLRcllDrimb99
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE+kgKfWry0BWjoQKURAtn5AJ9BjR6nM0/wS5oeusQwYTyLthDbzQCg4/DL
B4Vk3bprs4axtMk6nwcHcGs=
=7y8h
-----END PGP SIGNATURE-----

--5vNYLRcllDrimb99--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030407225839.GA60254>