1*40865Sbostic /*- 2*40865Sbostic * Copyright (c) 1979 The Regents of the University of California. 3*40865Sbostic * All rights reserved. 4*40865Sbostic * 5*40865Sbostic * %sccs.include.redist.c% 6*40865Sbostic */ 71677Smckusick 8*40865Sbostic #ifndef lint 9*40865Sbostic static char sccsid[] = "@(#)RANDOM.c 1.5 (Berkeley) 04/09/90"; 10*40865Sbostic #endif /* not lint */ 111677Smckusick 122181Smckusic #include "h00vars.h" 132181Smckusic 143017Smckusic extern long RAND(); 153017Smckusic 161677Smckusick double 171677Smckusick RANDOM() 181677Smckusick { 1910228Smckusick double d; 2010228Smckusick long l; 2110228Smckusick 221677Smckusick /* 2310228Smckusick * calculate (1103515245 * seed) mod 2^31-1 241677Smckusick */ 2510228Smckusick d = 1103515245.0 * _seed / 2147483647.0; 2610228Smckusick l = d; 2710228Smckusick d = d - l; 2810228Smckusick _seed = d * 2147483647.0; 2910228Smckusick /* 3010228Smckusick * want a value in the range 0..1 3110228Smckusick */ 3210228Smckusick return(d); 331677Smckusick } 34