From owner-freebsd-hackers Tue Feb 18 17:12:28 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BB52037B401 for ; Tue, 18 Feb 2003 17:12:26 -0800 (PST) Received: from obsecurity.dyndns.org (adsl-63-207-60-52.dsl.lsan03.pacbell.net [63.207.60.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id B18A343FBF for ; Tue, 18 Feb 2003 17:12:24 -0800 (PST) (envelope-from kris@obsecurity.org) Received: from rot13.obsecurity.org (rot13.obsecurity.org [10.0.0.5]) by obsecurity.dyndns.org (Postfix) with ESMTP id 48AD4679DA; Tue, 18 Feb 2003 17:12:24 -0800 (PST) Received: by rot13.obsecurity.org (Postfix, from userid 1000) id 2A4301197; Tue, 18 Feb 2003 17:12:24 -0800 (PST) Date: Tue, 18 Feb 2003 17:12:24 -0800 From: Kris Kennaway To: Paul Herman Cc: FreeBSD Hackers Subject: Re: arc4random() range Message-ID: <20030219011224.GI50962@rot13.obsecurity.org> References: <20030218153651.A240-100000@mammoth.eat.frenchfries.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="v2/QI0iRXglpx0hK" Content-Disposition: inline In-Reply-To: <20030218153651.A240-100000@mammoth.eat.frenchfries.net> User-Agent: Mutt/1.4i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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