From owner-freebsd-hackers Wed Feb 19 1: 5:44 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 BD4F537B401 for ; Wed, 19 Feb 2003 01:05:41 -0800 (PST) Received: from darius.concentric.net (darius.concentric.net [207.155.198.79]) by mx1.FreeBSD.org (Postfix) with ESMTP id 738DF43F93 for ; Wed, 19 Feb 2003 01:05:40 -0800 (PST) (envelope-from pherman@frenchfries.net) Received: from mcfeely.concentric.net (mcfeely.concentric.net [207.155.198.83]) by darius.concentric.net [Concentric SMTP Routing 1.0] id h1J95Yw08222 for ; Wed, 19 Feb 2003 04:05:35 -0500 (EST) Received: from mammoth.eat.frenchfries.net (da001d0041.lax-ca.osd.concentric.net [66.239.48.41]) by mcfeely.concentric.net (8.9.1a) id EAA05143; Wed, 19 Feb 2003 04:05:31 -0500 (EST) Received: by mammoth.eat.frenchfries.net (Postfix, from userid 1000) id 320624B4B; Wed, 19 Feb 2003 00:59:46 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mammoth.eat.frenchfries.net (Postfix) with ESMTP id 1AFDA4B45; Wed, 19 Feb 2003 00:59:46 -0800 (PST) Date: Wed, 19 Feb 2003 00:59:46 -0800 (PST) From: Paul Herman X-X-Sender: pherman@mammoth.eat.frenchfries.net To: phk@phk.freebsd.dk Cc: Peter Jeremy , FreeBSD Hackers Subject: Re: arc4random() range In-Reply-To: <77946.1045642969@critter.freebsd.dk> Message-ID: <20030219003725.W240-100000@mammoth.eat.frenchfries.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 On Wed, 19 Feb 2003 phk@phk.freebsd.dk wrote: > In message <20030218232210.T240-100000@mammoth.eat.frenchfries.net>, Paul Herma > n writes: > > > arc4random() returns random numbers in the range of 0 to > > (2**32)-1, and therefore has twice the range of RAND_MAX. > > Good. > > > EXAMPLES > > The following produces a drop-in replacement for the traditional > > random() and rand() functions using arc4random(): > > #define arc4random31() (arc4random() & 0x7FFFFFFF) > > Not good. Only true on 32 bit archs. Heh? random(3) produces numbers between 0 and RAND_MAX on my alpha. random(3) produces numbers between 0 and RAND_MAX on my i386. (arc4random() & 0x7FFFFFFF) produces numbers between 0 and RAND_MAX on my alpha. (arc4random() & 0x7FFFFFFF) produces numbers between 0 and RAND_MAX on my i386. I must not understand what you mean. OK Poul, I'll bite. :-) Could you please expound? bash-2.05$ uname -rm 4.5-RELEASE alpha bash-2.05b$ uname -rm 4.7-STABLE i386 -Paul. P.S. I hope you aren't nitpicking because of a missing (long) cast. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message