1 /*- 2 * Copyright (c) 1979, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)RANDOM.c 8.1 (Berkeley) 06/06/93"; 10 #endif /* not lint */ 11 12 #include "h00vars.h" 13 14 extern long RAND(); 15 16 double 17 RANDOM() 18 { 19 double d; 20 long l; 21 22 /* 23 * calculate (1103515245 * seed) mod 2^31-1 24 */ 25 d = 1103515245.0 * _seed / 2147483647.0; 26 l = d; 27 d = d - l; 28 _seed = d * 2147483647.0; 29 /* 30 * want a value in the range 0..1 31 */ 32 return(d); 33 } 34