From owner-freebsd-hackers Wed Feb 19 0:22:55 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 184A637B401 for ; Wed, 19 Feb 2003 00:22:54 -0800 (PST) Received: from phk.freebsd.dk (phk.freebsd.dk [212.242.86.175]) by mx1.FreeBSD.org (Postfix) with ESMTP id 56DA943FAF for ; Wed, 19 Feb 2003 00:22:52 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by phk.freebsd.dk (8.12.6/8.12.6) with ESMTP id h1J8Mo6E089615; Wed, 19 Feb 2003 08:22:51 GMT (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.6/8.12.6) with ESMTP id h1J8MnOx077947; Wed, 19 Feb 2003 09:22:49 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: Paul Herman Cc: Peter Jeremy , FreeBSD Hackers Subject: Re: arc4random() range From: phk@phk.freebsd.dk In-Reply-To: Your message of "Wed, 19 Feb 2003 00:16:57 PST." <20030218232210.T240-100000@mammoth.eat.frenchfries.net> Date: Wed, 19 Feb 2003 09:22:49 +0100 Message-ID: <77946.1045642969@critter.freebsd.dk> 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 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. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message