1 
2 /*-
3 Dr. Park's algorithm published in the Oct. '88 ACM
4 "Random Number Generators: Good Ones Are Hard To Find"
5 His version available at ftp://cs.wm.edu/pub/rngs.tar
6 Present form by many authors.
7 */
8 
9 static int  Seed = 1;		/* This is required to be 32 bits long */
10 
11 /*
12  *      Given an integer, this routine initializes the RNG seed.
13  */
14 void
SetRNG(long int s)15 SetRNG(long int s)
16 {
17 	Seed = (int) s;
18 }
19 
20 /*
21  *      Returns an integer between 0 and 2147483647, inclusive.
22  */
23 long
LongRNG(void)24 LongRNG(void)
25 {
26 	if ((Seed = Seed % 44488 * 48271 - Seed / 44488 * 3399) < 0)
27 		Seed += 2147483647;
28 	return (long) (Seed - 1);
29 }
30