BSD libc default rand()
Usage
For random numbers generated using rand() from BSD.
Generator
Seed:
Seed Range
Unsigned Integer (32-bit)
Seed Size: 31 bits
Default Seed: 1
Definition
MCG
X
0 = Seed
X
n+1 = 16807 X
n mod 2147483647 (X
n is replaced by 123459876 if it is 0)
Initial Output: X
1
Output: X
Range: 1 ~ 2147483646
Sample Code for 100 Values (C):
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
if (argc >= 2) {
srand(atoi(argv[1]));
}
int i;
for (i = 0; i < 100; ++i){
printf("%d ", rand());
};
return 0;
}