140865Sbostic /*- 2*62094Sbostic * Copyright (c) 1979, 1993 3*62094Sbostic * The Regents of the University of California. All rights reserved. 440865Sbostic * 540865Sbostic * %sccs.include.redist.c% 640865Sbostic */ 71677Smckusick 840865Sbostic #ifndef lint 9*62094Sbostic static char sccsid[] = "@(#)RANDOM.c 8.1 (Berkeley) 06/06/93"; 1040865Sbostic #endif /* not lint */ 111677Smckusick 122181Smckusic #include "h00vars.h" 132181Smckusic 143017Smckusic extern long RAND(); 153017Smckusic 161677Smckusick double RANDOM()171677SmckusickRANDOM() 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