Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!seismo!hao!hplabs!sri-unix!Eldridge.es@PARC-MAXC.ARPA From: Eldridge.es@PARC-MAXC.ARPA Newsgroups: net.micro.cpm Subject: Re: RANDOM in Pascal Message-ID: <14569@sri-arpa.UUCP> Date: Tue, 13-Dec-83 11:38:00 EST Article-I.D.: sri-arpa.14569 Posted: Tue Dec 13 11:38:00 1983 Date-Received: Fri, 16-Dec-83 03:31:28 EST Lines: 28 Try the following (I use it in JRT Pascal): function Random(Seed : real): real; { Return the next value in a pseudo-random sequence. The range is 0<=N<1. } begin Seed := (9821.0 * Seed) + 0.211327; Seed := Seed - trunc(Seed); Random := Seed end; {Random} Initialize the random number generator by giving it a first seed. (RandNum and StartValue are both real) RandNum := Random(StartValue); Succeeding numbers in the sequence are generated by: RandNum := Random(RandNum); The formula used is: NextSeed = frac((9821.0 * Seed) + 0.211327) This is the formula in the HP-41C standard applications library. George