Commit | Line | Data |
---|---|---|
da3b1b0b | 1 | /* |
be6e3ddf RE |
2 | * Copyright (c) 1980 Regents of the University of California. |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
da3b1b0b | 5 | * |
eda8efe9 RE |
6 | * @(#)random_.c 5.2 %G% |
7 | * | |
da3b1b0b RC |
8 | * Routines to return random values |
9 | * | |
10 | * calling sequence: | |
11 | * double precision d, drandm | |
12 | * i = irandm(iflag) | |
13 | * x = random(iflag) | |
14 | * d = drandm(iflag) | |
15 | * where: | |
16 | * If arg is nonzero, generator is restarted and value is returned. | |
17 | * If arg is 0, next value is returned. | |
18 | * Integer values will range from 0 thru 2147483647 (see random(3)). | |
19 | * Real values will range from 0.0 thru 1.0 . | |
20 | */ | |
21 | ||
22 | #if vax | |
23 | #define RANDMAX 2147483647 | |
24 | #else vax | |
25 | UNKNOWN MACHINE! | |
26 | #endif vax | |
27 | ||
28 | long irandm_(iarg) | |
29 | long *iarg; | |
30 | { | |
31 | if (*iarg) srandom((int)*iarg); | |
32 | return( random() ); | |
33 | } | |
34 | ||
35 | float random_(iarg) | |
36 | long *iarg; | |
37 | { | |
38 | if (*iarg) srandom((int)*iarg); | |
39 | return( (float)(random())/(float)RANDMAX ); | |
40 | } | |
41 | ||
42 | double drandm_(iarg) | |
43 | long *iarg; | |
44 | { | |
45 | if (*iarg) srandom((int)*iarg); | |
46 | return( (double)(random())/(double)RANDMAX ); | |
47 | } |