Commit | Line | Data |
---|---|---|
8ac21c23 KT |
1 | .th RAND III 1/15/73 |
2 | .sh NAME | |
3 | rand \*- random number generator | |
4 | .sh SYNOPSIS | |
5 | (seed in r0) | |
6 | .br | |
7 | .ft B | |
8 | jsr pc,srand /to initialize | |
9 | .s3 | |
10 | jsr pc,rand /to get a random number | |
11 | .s3 | |
12 | .nf | |
13 | srand(seed) | |
14 | int seed; | |
15 | .s3 | |
16 | rand( ) | |
17 | .fi | |
18 | .ft R | |
19 | .s3 | |
20 | .sh DESCRIPTION | |
21 | .it Rand | |
22 | uses a multiplicative congruential | |
23 | random number generator to return successive pseudo-random | |
24 | numbers (in r0) in the range from 1 to 2\u\s715\s10\d\*-1. | |
25 | .s3 | |
26 | The generator is reinitialized by calling | |
27 | .it srand | |
28 | with 1 as argument (in r0). | |
29 | It can be set to a random starting point by calling | |
30 | .it srand | |
31 | with whatever you like as argument, | |
32 | for example the low-order word | |
33 | of the time. | |
34 | .sh WARNING | |
35 | The author of this routine has been writing | |
36 | random-number generators for many years and has never been | |
37 | known to write one that worked. | |
38 | .sh BUGS | |
39 | The low-order bits are not very random. |