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