Date: Fri, 21 Feb 2003 11:29:00 +1030 From: Greg 'groggy' Lehey <grog@FreeBSD.org> To: Wes Peters <wes@softweyr.com> Cc: Peter Jeremy <peterjeremy@optushome.com.au>, Paul Herman <pherman@frenchfries.net>, FreeBSD Hackers <hackers@FreeBSD.ORG> Subject: Re: arc4random() range Message-ID: <20030221005900.GG84517@wantadilla.lemis.com> In-Reply-To: <200302190922.18146.wes@softweyr.com> References: <20030219013247.GA10910@x-anthony.com> <20030218180736.L240-100000@mammoth.eat.frenchfries.net> <20030219063646.GB62020@cirb503493.alcatel.com.au> <200302190922.18146.wes@softweyr.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--8bBEDOJVaa9YlTAt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wednesday, 19 February 2003 at 9:22:18 -0800, Wes Peters wrote: > On Tuesday 18 February 2003 22:36, Peter Jeremy wrote: >> >> I see this as a major advantage of arc4random() - if I want 32-bit >> random numbers I don't have to call random() twice and merge the >> results. I've never understood why random() was specified to return >> a '0' in the MSB. > > It probably had something to do with the PDP-11 architecture. This > rings a bell, but I can't recall what it was. Greg Lehey might be > able to help here, he has far better knowlege of the Good Old Days(tm) > than I do.=20 Difficult to say. I don't think that random() was in the Seventh Edition. They used rand() instead. Read the code and shudder: static long randx =3D 1; srand(x) unsigned x; { randx =3D x; } rand() { return(((randx =3D randx*1103515245 + 12345)>>16) & 077777); } That's the entire content of Seventh Edition /usr/src/libc/gen/rand.c. Greg -- See complete headers for address and phone numbers Please note: we block mail from major spammers, notably yahoo.com. See http://www.lemis.com/yahoospam.html for further details. --8bBEDOJVaa9YlTAt Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (FreeBSD) iD8DBQE+VXnUIubykFB6QiMRAk2/AKCD2dlaSVKw2X87WIt4pn/q+P4kXQCePaG8 JHbCPtSKY4TS8RfFQtbbKmY= =FBKr -----END PGP SIGNATURE----- --8bBEDOJVaa9YlTAt-- 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?20030221005900.GG84517>