From owner-freebsd-current Sun Feb 2 14:37:30 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 ED2B337B405 for ; Sun, 2 Feb 2003 14:37:28 -0800 (PST) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.208.78.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B7E443FB1 for ; Sun, 2 Feb 2003 14:37:28 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.12.6/8.12.6) with ESMTP id h12MbQXv073032; Sun, 2 Feb 2003 14:37:26 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.12.6/8.12.6/Submit) id h12MbPqC073031; Sun, 2 Feb 2003 14:37:25 -0800 (PST) Date: Sun, 2 Feb 2003 14:37:25 -0800 From: Steve Kargl To: Bakul Shah Cc: Mark Murray , current@FreeBSD.ORG Subject: Re: rand() is broken Message-ID: <20030202223725.GA72744@troutmask.apl.washington.edu> References: <200302022106.h12L6naX051530@grimreaper.grondar.org> <200302022159.QAA13933@wellington.cnchost.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200302022159.QAA13933@wellington.cnchost.com> User-Agent: Mutt/1.4i 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, Feb 02, 2003 at 01:59:25PM -0800, Bakul Shah wrote: > > AFAIK all random(3) implementations in various versions of > Unix come from Earl's original 4.2BSD implementation so in my > view the _expected_ behavior is to see the _exact_ same > sequence starting from a given seed. This function is called > "random()" but it is equivalent to a mathematical function > which must provide the same sequence for the exact same > input. > I was going to stay out of this, but #include #include int main(void) { int i; long x; x = 100L; srandom(x); for (i = 0; i < 1010; i++) { x = random(); printf("%ld\n", x); } return 0; } Last 10 digits. FreeBSD Redhat SunOS 660787754 660787754 645318364 327548691 327548691 1583150371 2009993994 2009993994 715222008 1653966416 1653966416 1349166998 1074113008 1074113008 566227131 2142626740 2142626740 1382825076 1517775852 1517775852 583981903 1453318125 1453318125 1453942393 619607807 619607807 1952958724 199986393 199986393 1599163286 -- Steve To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message