Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Feb 2003 17:12:24 -0800
From:      Kris Kennaway <kris@obsecurity.org>
To:        Paul Herman <pherman@frenchfries.net>
Cc:        FreeBSD Hackers <hackers@FreeBSD.ORG>
Subject:   Re: arc4random() range
Message-ID:  <20030219011224.GI50962@rot13.obsecurity.org>
In-Reply-To: <20030218153651.A240-100000@mammoth.eat.frenchfries.net>
References:  <20030218153651.A240-100000@mammoth.eat.frenchfries.net>

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

--v2/QI0iRXglpx0hK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Feb 18, 2003 at 04:04:57PM -0800, Paul Herman wrote:

> What's the concesus that arc4random() should be a drop-in
> replacement for rand()/random()?  Consider the following that
> caclulates the average of a bunch of random numbers on [0.0, 1.0]:

rand() and random() return signed values (int and long respectively).
arc4random() returns an uint32_t.  This explains the shift of 0.5 in
your result.

Kris

--v2/QI0iRXglpx0hK
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQE+Utn3Wry0BWjoQKURApFGAJwPXBvvhDv2X3QFjr/jGOHmTHKGjwCgxaeO
e1iS6VsRa06VYnoewbb8ZUA=
=fBvj
-----END PGP SIGNATURE-----

--v2/QI0iRXglpx0hK--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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