From owner-freebsd-current Wed Feb 5 10:56:39 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 01E7D37B401; Wed, 5 Feb 2003 10:56:38 -0800 (PST) Received: from haldjas.folklore.ee (Haldjas.folklore.ee [193.40.6.121]) by mx1.FreeBSD.org (Postfix) with ESMTP id B2A7C43FA3; Wed, 5 Feb 2003 10:56:36 -0800 (PST) (envelope-from narvi@haldjas.folklore.ee) Received: from haldjas.folklore.ee (localhost [127.0.0.1]) by haldjas.folklore.ee (8.12.3/8.11.3) with ESMTP id h15IuYOs010090; Wed, 5 Feb 2003 20:56:34 +0200 (EET) (envelope-from narvi@haldjas.folklore.ee) Received: from localhost (narvi@localhost) by haldjas.folklore.ee (8.12.3/8.12.3/Submit) with ESMTP id h15IuPdt010087; Wed, 5 Feb 2003 20:56:25 +0200 (EET) Date: Wed, 5 Feb 2003 20:56:25 +0200 (EET) From: Narvi To: phk@FreeBSD.ORG Cc: "Andrey A. Chernov" , Mark Murray , Doug Barton , Kris Kennaway , Subject: Re: rand() is broken In-Reply-To: <31532.1044211424@critter.freebsd.dk> Message-ID: <20030205205444.S43637-100000@haldjas.folklore.ee> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 2 Feb 2003 phk@FreeBSD.ORG wrote: > In message <20030202183826.GA66487@nagual.pp.ru>, "Andrey A. Chernov" writes: > >On Sun, Feb 02, 2003 at 19:32:50 +0100, phk@freebsd.org wrote: > >> > >> Anyway, last time we discussed this, I think we stuck with the rand() > >> we had because we feared that people were using it's repeatable well > >> documented sequence of random numbers in regression testing. > > > >As documented, it must be repeatable across the calls for same seed, that > >is all. It not means repeatable accross platforms or across different OS > >versions. In fact it is already not repeatable across different OS'es, so > >regression is limited. Also, regression must not stop bugs fixing progress > >in anycase. > > Our manual pages do not comprehensively list all compatibility > concerns or concessions, waving our manpage about does not address > the concern. > > As I said, I don't know how big a concern this is. But last time > it was enough of a concern to make us keep rand() as it was. > man srand on another system (for what its worth) says: The rand() function uses a multiplicative congruential random-number generator with period 2**32 that returns suc- cessive pseudo-random numbers in the range of 0 to RAND_MAX (defined in ). The srand() function uses the argument seed as a seed for a new sequence of pseudo-random numbers to be returned by sub- sequent calls to rand(). If srand() is then called with the same seed value, the sequence of pseudo-random numbers will be repeated. If rand() is called before any calls to srand() have been made, the same sequence will be generated as when srand() is first called with a seed value of 1. > Please surf the mail-archives to find the discussion, it contained > a lot of good arguments from both sides, arguments which should > be thought about before changing rand(). > > -- > 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-current" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message