Generates pseudorandom numbers in a more random sequence.
#include <stdlib.h> long int random (void);
The random function uses a nonlinear additive feedback random number generator employing a default state array size of 31 integers to return successive pseudorandom numbers in the range from 0 to ( 231 )-1. The period of this random number generator is approximately 16*(( 231 )-1). The size of the state array determines the period of the random number generator. Increasing the state array size increases the period.
With a full 256 bytes of state information, the period of the random number generator is greater than 269 , and is sufficient for most purposes.
Like the rand function, the random function produces by default a sequence of numbers that you can duplicate by calling the srandom function with a value of 1 as the seed. The srandom function, unlike the srand function, does not return the old seed because the amount of state information used is more than a single word.
See also rand, srand, and srandom in this section.
n | A random number. |