|
|
1.1 root 1: /*
2: * @(#)random_.c 2.1
3: *
4: * Routines to return random values
5: *
6: * calling sequence:
7: * double precision d, drandm
8: * i = irandm(iflag)
9: * x = random(iflag)
10: * d = drandm(iflag)
11: * where:
12: * If arg is nonzero, generator is restarted and value is returned.
13: * If arg is 0, next value is returned.
14: * Integer values will range from 0 thru 2147483647 (see random(3)).
15: * Real values will range from 0.0 thru 1.0 .
16: */
17:
18: #define RANDMAX 2147483647
19:
20: long irandm_(iarg)
21: long *iarg;
22: {
23: if (*iarg) srandom((int)*iarg);
24: return( random() );
25: }
26:
27: float random_(iarg)
28: long *iarg;
29: {
30: if (*iarg) srandom((int)*iarg);
31: return( (float)(random())/(float)RANDMAX );
32: }
33:
34: double drandm_(iarg)
35: long *iarg;
36: {
37: if (*iarg) srandom((int)*iarg);
38: return( (double)(random())/(double)RANDMAX );
39: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.