|Skip Navigation Links|
|Exit Print View|
|man pages section 3: Basic Library Functions Oracle Solaris 10 8/11 Information Library|
- simple random number generator
/usr/ucb/cc [ flag ... ] file ... int rand();
int srand(seed) unsigned seed;
rand() uses a multiplicative congruential random number generator with period 232 to return successive pseudo-random numbers in the range from 0 to 231 - 1.
srand() can be called at any time to reset the random-number generator to a random starting point. The generator is initially seeded with a value of 1.
Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported.
The low bits of the numbers generated are not very random; use the middle bits. In particular the lowest bit alternates between 0 and 1.