Date: Wed, 19 Feb 2003 10:14:20 +0100 From: phk@phk.freebsd.dk To: Paul Herman <pherman@frenchfries.net> Cc: Peter Jeremy <peterjeremy@optushome.com.au>, FreeBSD Hackers <hackers@FreeBSD.ORG> Subject: Re: arc4random() range Message-ID: <86890.1045646060@critter.freebsd.dk> In-Reply-To: Your message of "Wed, 19 Feb 2003 00:59:46 PST." <20030219003725.W240-100000@mammoth.eat.frenchfries.net>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <20030219003725.W240-100000@mammoth.eat.frenchfries.net>, Paul Herma n writes: >> >> > 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. Well, I'm right in principle but wrong in current practice, at the very least make it: #define arc4random31() (arc4random() & RAND_MAX) -- 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86890.1045646060>