From owner-freebsd-hackers Sun Feb 23 21:16:59 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 93AAD37B401 for ; Sun, 23 Feb 2003 21:16:57 -0800 (PST) Received: from echunga.lemis.com (gregl1.lnk.telstra.net [139.130.136.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D88643FBF for ; Sun, 23 Feb 2003 21:16:52 -0800 (PST) (envelope-from grog@lemis.com) Received: by wantadilla.lemis.com (Postfix, from userid 1004) id C157A51A3A; Fri, 21 Feb 2003 11:29:00 +1030 (CST) Date: Fri, 21 Feb 2003 11:29:00 +1030 From: Greg 'groggy' Lehey To: Wes Peters Cc: Peter Jeremy , Paul Herman , FreeBSD Hackers Subject: Re: arc4random() range Message-ID: <20030221005900.GG84517@wantadilla.lemis.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> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8bBEDOJVaa9YlTAt" Content-Disposition: inline In-Reply-To: <200302190922.18146.wes@softweyr.com> User-Agent: Mutt/1.4i Organization: The FreeBSD Project Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.FreeBSD.org/ X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 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 --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