Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!seismo!hao!hplabs!sri-unix!ciaraldi@Rochester.ARPA From: ciaraldi@Rochester.ARPA Newsgroups: net.micro.cpm Subject: Re: RANDOM in Pascal Message-ID: <14557@sri-arpa.UUCP> Date: Mon, 12-Dec-83 22:42:50 EST Article-I.D.: sri-arpa.14557 Posted: Mon Dec 12 22:42:50 1983 Date-Received: Fri, 16-Dec-83 03:28:05 EST Lines: 21 From: Mike Ciaraldi I have seen a Pascal pseudo-random number generator prrogram. I uses the well-know techinque of taking a seed number, multiplying it by a constant, adding another constant, and using the result as a random integer, and also as the next seed. The problem is finding the "magic numbers" for the constants. Someone has figured this out for various word lengths, and I know a set of constants exists which causes a 16-bit integer to cycle in a pseudo-random fashion through all 64k numbers. This is then easily converted into a fraction between 0 and 1.0. The algorithm I saw was written up in some sample programs which came with the Motorola Pascal compiler (produces 6809 code on an IBM 360). I think the magic numbers are listed in the "Encyclopedia of Computer Science", edited by Anthony Ralston. You might also try the ACM collected Algortiithms. Mike Ciaraldi ciaraldi@rochester