1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)random_.c 5.5 (Berkeley) 04/12/91"; 10 #endif /* not lint */ 11 12 /* 13 * Routines to return random values 14 * 15 * calling sequence: 16 * double precision d, drandm 17 * i = irandm(iflag) 18 * x = random(iflag) 19 * d = drandm(iflag) 20 * where: 21 * If arg is nonzero, generator is restarted and value is returned. 22 * If arg is 0, next value is returned. 23 * Integer values will range from 0 thru 2147483647 (see random(3)). 24 * Real values will range from 0.0 thru 1.0 . 25 */ 26 27 #if defined(vax) || defined(tahoe) || defined(hp300) 28 #define RANDMAX 2147483647 29 #else vax || tahoe 30 UNKNOWN MACHINE! 31 #endif vax || tahoe 32 irandm_(iarg)33long irandm_(iarg) 34 long *iarg; 35 { 36 if (*iarg) srandom((int)*iarg); 37 return( random() ); 38 } 39 random_(iarg)40float random_(iarg) 41 long *iarg; 42 { 43 if (*iarg) srandom((int)*iarg); 44 return( (float)(random())/(float)RANDMAX ); 45 } 46 drandm_(iarg)47double drandm_(iarg) 48 long *iarg; 49 { 50 if (*iarg) srandom((int)*iarg); 51 return( (double)(random())/(double)RANDMAX ); 52 } 53