| Rev | Author | # | Line |
|---|---|---|---|
| 1 | perry | 1 | !!NAME |
| 2 | |||
| 3 | |||
| 4 | random, srandom, initstate, setstate - random number generator. | ||
| 5 | !!SYNOPSIS | ||
| 4 | StuartYeates | 6 | #include <stdlib.h> |
| 7 | long int random(void); | ||
| 8 | void srandom(unsigned int __''seed''__); | ||
| 9 | char *initstate(unsigned int __''seed''__, char *state, size_t __''n''__); | ||
| 10 | char *setstate(char *__''state''__); | ||
| 1 | perry | 11 | |
| 12 | !!DESCRIPTION | ||
| 13 | |||
| 14 | |||
| 15 | The __random()__ function uses a non-linear additive | ||
| 16 | feedback random number generator employing a default table | ||
| 17 | of size 31 long integers to return successive pseudo-random | ||
| 18 | numbers in the range from 0 to __RAND_MAX__. The period | ||
| 19 | of this random number generator is very large, approximately | ||
| 20 | 16*((2**31)-1). | ||
| 21 | |||
| 22 | |||
| 23 | The __srandom()__ function sets its argument as the seed | ||
| 24 | for a new sequence of pseudo-random integers to be returned | ||
| 25 | by __random()__. These sequences are repeatable by | ||
| 26 | calling __srandom()__ with the same seed value. If no | ||
| 27 | seed value is provided, the __random()__ function is | ||
| 28 | automatically seeded with a value of 1. | ||
| 29 | |||
| 30 | |||
| 31 | The __initstate()__ function allows a state array | ||
| 32 | ''state'' to be initialized for use by __random()__. | ||
| 33 | The size of the state array ''n'' is used by | ||
| 34 | __initstate()__ to decide how sophisticated a random | ||
| 35 | number generator it should use -- the larger the state | ||
| 36 | array, the better the random numbers will be. ''seed'' is | ||
| 37 | the seed for the initialization, which specifies a starting | ||
| 38 | point for the random number sequence, and provides for | ||
| 39 | restarting at the same point. | ||
| 40 | |||
| 41 | |||
| 42 | The __setstate()__ function changes the state array used | ||
| 43 | by the __random()__ function. The state array | ||
| 44 | ''state'' is used for random number generation until the | ||
| 45 | next call to __initstate()__ or __setstate()__. | ||
| 46 | ''state'' must first have been initialized using | ||
| 47 | __initstate()__ or be the result of a previous call of | ||
| 48 | __setstate()__. | ||
| 49 | !!RETURN VALUE | ||
| 50 | |||
| 51 | |||
| 52 | The __random()__ function returns a value between 0 and | ||
| 53 | RAND_MAX. The __srandom()__ function returns no value. | ||
| 54 | The __initstate()__ and __setstate()__ functions | ||
| 55 | return a pointer to the previous state array, or NULL on | ||
| 56 | error. | ||
| 57 | !!ERRORS | ||
| 58 | |||
| 59 | |||
| 60 | __EINVAL__ | ||
| 61 | |||
| 62 | |||
| 63 | A state array of less than 8 bytes was specified to | ||
| 64 | __initstate()__. | ||
| 65 | !!NOTES | ||
| 66 | |||
| 67 | |||
| 68 | Current | ||
| 69 | n'' are 8, 32, 64, 128, and 256 bytes; other | ||
| 70 | amounts will be rounded down to the nearest known amount. | ||
| 71 | Using less than 8 bytes will cause an error. | ||
| 72 | !!CONFORMING TO | ||
| 73 | |||
| 74 | |||
| 75 | BSD 4.3 | ||
| 76 | !!SEE ALSO | ||
| 77 | |||
| 78 | |||
| 2 | StuartYeates | 79 | rand(3), srand(3), [random(3)], [random(4)], [srandom(3)] and [urandom(4)] |
| 1 | perry | 80 | ---- |
lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 2 times)