diff options
Diffstat (limited to 'src/prng/rand.c')
-rw-r--r-- | src/prng/rand.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/prng/rand.c b/src/prng/rand.c new file mode 100644 index 00000000..e3ce6347 --- /dev/null +++ b/src/prng/rand.c @@ -0,0 +1,13 @@ +#include <stdlib.h> + +static unsigned seed; + +void srand(unsigned s) +{ + seed = s-1; +} + +int rand(void) +{ + return (seed = (seed+1) * 1103515245 + 12345 - 1)+1 & 0x7fffffff; +} |