From owner-freebsd-current Mon Feb 3 5:59:51 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 4B82937B401 for ; Mon, 3 Feb 2003 05:59:50 -0800 (PST) Received: from HAL9000.homeunix.com (12-233-57-224.client.attbi.com [12.233.57.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id BAAE643F9B for ; Mon, 3 Feb 2003 05:59:49 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.6/8.12.5) with ESMTP id h13DxkZh001058; Mon, 3 Feb 2003 05:59:46 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id h13Dxjdg001057; Mon, 3 Feb 2003 05:59:45 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Date: Mon, 3 Feb 2003 05:59:45 -0800 From: David Schultz To: Thomas David Rivers Cc: ache@nagual.pp.ru, kris@obsecurity.org, current@FreeBSD.ORG Subject: Re: Final fix for correlation problem (was Re: rand() is broken) Message-ID: <20030203135945.GB985@HAL9000.homeunix.com> Mail-Followup-To: Thomas David Rivers , ache@nagual.pp.ru, kris@obsecurity.org, current@FreeBSD.ORG References: <20030203114629.GA77557@nagual.pp.ru> <200302031201.h13C1oE03172@lakes.dignus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200302031201.h13C1oE03172@lakes.dignus.com> 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 Thus spake Thomas David Rivers : > I'm afraid I don't understand the fix... and how it > seems to affect the historical behaviour of srand()/rand(). > > How does it address the understanding that if I use > srand(28), I will get exactly the same sequence of > numbers srand(28) produced yesterday, last week, > last year? > > I have worked with programs that depend on exactly > that behavior. > > That is, given the same input seed - I expect > to see the same "random" sequence again. > > This requirement would seem to indicate that changing > srand()/rand() isn't really possible... And, also, > I believe, why random() was introduced... > > Please, oh please, don't change that behavior in > srand()/rand(). There are two sides to this argument. One side says that rand() should always produce the same sequence for a given seed no matter what. This argument is bogus, because if you need exact reproducability across all platforms for all time, you should be using your own PRNG. The other side says that rand() should be a reasonably good RNG for most applications. It would be nice if things worked out that way, but there are enough broken rand() implementations out there that most people don't rely upon them. So I'd be inclined to call this argument bogus as well, except that I know someone who has been burned by a bad rand() while trying to test a randomized graph algorithm in C. My final thoughts are that having a better rand() implementation is a Good Thing, but it isn't that big a deal, and it certainly isn't worth all of this bickering. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message