From owner-freebsd-current Tue Feb 4 6:23:32 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 3237E37B401 for ; Tue, 4 Feb 2003 06:23:31 -0800 (PST) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id D7D8A43F43 for ; Tue, 4 Feb 2003 06:23:29 -0800 (PST) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id C7691536E; Tue, 4 Feb 2003 15:23:28 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: "Andrey A. Chernov" Cc: David Schultz , Kris Kennaway , current@FreeBSD.ORG Subject: Re: rand() is broken From: Dag-Erling Smorgrav Date: Tue, 04 Feb 2003 15:23:28 +0100 In-Reply-To: <20030204140052.GA93115@nagual.pp.ru> ("Andrey A. Chernov"'s message of "Tue, 4 Feb 2003 17:00:52 +0300") Message-ID: User-Agent: Gnus/5.090014 (Oort Gnus v0.14) Emacs/21.2 (i386--freebsd) References: <20030202090422.GA59750@nagual.pp.ru> <20030203002639.GB44914@HAL9000.homeunix.com> <20030203100002.GA73386@nagual.pp.ru> <20030204054020.GA2447@HAL9000.homeunix.com> <20030204094659.GA87303@nagual.pp.ru> <20030204115237.GA6483@HAL9000.homeunix.com> <20030204131006.GB92301@nagual.pp.ru> <20030204131748.GA92510@nagual.pp.ru> <20030204140052.GA93115@nagual.pp.ru> 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 "Andrey A. Chernov" writes: > On Tue, Feb 04, 2003 at 14:43:57 +0100, Dag-Erling Smorgrav wrote: > > All that being said, adding 1 to *ctx before returning it (see patch) > > adresses both of your objections: a seed of 0 will not cause the LCG > > to get stuck, and the result of rand() will range between 0 and > > RAND_MAX inclusive. > Adding +1 you break algorithm formulae badly from math point of view, > something else then given formulae not allowed here. You can change 'a' > parameter to anything you want, but not add something at the end. Do the math - adding 1 after the modulo operation is equivalent to setting a == k. DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message