From owner-freebsd-current Fri Mar 29 05:59:43 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id FAA13120 for current-outgoing; Fri, 29 Mar 1996 05:59:43 -0800 (PST) Received: from sovcom.kiae.su (sovcom.kiae.su [144.206.136.1]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id FAA13083 for ; Fri, 29 Mar 1996 05:59:24 -0800 (PST) Received: by sovcom.kiae.su id AA10544 (5.65.kiae-1 ); Fri, 29 Mar 1996 16:49:14 +0300 Received: by sovcom.KIAE.su (UUMAIL/2.0); Fri, 29 Mar 96 16:49:13 +0300 Received: (from ache@localhost) by astral.msk.su (8.7.5/8.7.3) id QAA00701; Fri, 29 Mar 1996 16:46:22 +0300 (MSK) Message-Id: <199603291346.QAA00701@astral.msk.su> Subject: Re: random .. not so .. To: imb@scgt.oz.au (michael butler) Date: Fri, 29 Mar 1996 16:46:22 +0300 (MSK) Cc: current@freebsd.org In-Reply-To: <199603290938.UAA12872@asstdc.scgt.oz.au> from "michael butler" at "Mar 29, 96 08:38:17 pm" From: =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA_=FE=C5=D2=CE=CF=D7?= (aka Andrey A. Chernov, Black Mage) X-Class: Fast X-Mailer: ELM [version 2.4ME+ PL14 (25)] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > BSD: state[i] = 1103515245 * state[i - 1] + 12345; > > Linux: state[i] = 1103515145 * state[i - 1] + 12345; > > ^ > That line is utterly WRONG in BOTH implementations. The state it creates > is so incredibly UNRANDOM, that seeding is almost pointless. The following > program outputs a PBM image showing a bit in the result of successive calls > to random(), for consecutive values of srandom(). > > The results are TERRIBLE (for example, the 151st value returned by random() > is 0 for seed 0..14, then 1 for seed 15..30, then 0 for seed 31..46, etc.) Yes, the bug really hits, here is some of FreeBSD-current results, very visible patterns exists. They created by proposed program: a | split -l 100; paste x[a-b]* | tr -d "\t" I plan to aply proposed fix, if nobody against. 1100110011001100110011001100110011001100110011001100 1010101010101010101010101010101010101010101010101010 0110011001100110011001100110011001100110011001100110 1010101010101010101010101010101010101010101010101010 0101010101010101010101010101010101010101010101010101 1100110011001100110011001100110011001100110011001100 1010101010101010101010101010101010101010101010101010 0101010101010101010101010101010101010101010101010101 0110011001100110011001100110011001100110011001100110 0011001100110011001100110011001100110011001100110011 1100110011001100110011001100110011001100110011001100 0110011001100110011001100110011001100110011001100110 1100110011001100110011001100110011001100110011001100 1010101010101010101010101010101010101010101010101010 1100110011001100110011001100110011001100110011001100 0101010101010101010101010101010101010101010101010101 1100110011001100110011001100110011001100110011001100 1001100110011001100110011001100110011001100110011001 0011001100110011001100110011001100110011001100110011 0011001100110011001100110011001100110011001100110011 1001100110011001100110011001100110011001100110011001 1111111111111111111111111111111111111111111111111111 1010101010101010101010101010101010101010101010101010 0000000000000000000000000000000000000000000000000000 0101010101010101010101010101010101010101010101010101 1111111111111111111111111111111111111111111111111111 1100110011001100110011001100110011001100110011001100 0110011001100110011001100110011001100110011001100110 -- Andrey A. Chernov : And I rest so composedly, /Now, in my bed, ache@astral.msk.su : That any beholder /Might fancy me dead - http://dt.demos.su/~ache : Might start at beholding me, /Thinking me dead. RELCOM Team,FreeBSD Team : E.A.Poe From "For Annie" 1849