From owner-freebsd-current Sun Feb 2 9:36:58 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 BFADB37B406; Sun, 2 Feb 2003 09:36:55 -0800 (PST) Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.157.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 690F443F79; Sun, 2 Feb 2003 09:36:54 -0800 (PST) (envelope-from mark@grondar.org) Received: from storm.FreeBSD.org.uk (Ugrondar@localhost [127.0.0.1]) by storm.FreeBSD.org.uk (8.12.6/8.12.6) with ESMTP id h12HarLf077955; Sun, 2 Feb 2003 17:36:53 GMT (envelope-from mark@grondar.org) Received: (from Ugrondar@localhost) by storm.FreeBSD.org.uk (8.12.6/8.12.6/Submit) with UUCP id h12Har7F077954; Sun, 2 Feb 2003 17:36:53 GMT X-Authentication-Warning: storm.FreeBSD.org.uk: Ugrondar set sender to mark@grondar.org using -f Received: from grondar.org (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.6/8.12.6) with ESMTP id h12HWvaX048978; Sun, 2 Feb 2003 19:32:57 +0200 (SAST) (envelope-from mark@grondar.org) From: Mark Murray Message-Id: <200302021732.h12HWvaX048978@grimreaper.grondar.org> To: "Andrey A. Chernov" Cc: Tim Robbins , Kris Kennaway , current@FreeBSD.ORG Subject: Re: rand() is broken In-Reply-To: Your message of "Sun, 02 Feb 2003 16:42:25 +0300." <20030202134225.GA63673@nagual.pp.ru> Date: Sun, 02 Feb 2003 17:32:57 +0000 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 Mon, Feb 03, 2003 at 00:17:35 +1100, Tim Robbins wrote: > > > > I believe that this change just moves the "bad" seed to 123459876; after > > calling srand() with that seed, each call to rand() returns 0. > > Yes. Nothing better is possible for this formulae and this is documented > in algorithm, some value must be excluded. Excluding 0 is bad only because > srand(0) is commonly used and srand(123459876) is not. This means that this routine has a chance of failing spectacularly. We should not use it. > Ragarding to old formulae, the question is: what is worse, generate > non-random lover bits everytime (old variant) or exclude one seed value > (new variant)? Neither. New RNG is needed. > Of course formulae can be changed to some another algorithm, but keep in > mind that rand() must be simple and speedy. Now used variant is most > simpler, others are much more complex. RC4 is fast. RC4 is simple. Any objections? :-) M -- Mark Murray iumop ap!sdn w,I idlaH To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message