prng: make rand_r have 2^32 period instead of 2^31
authorSzabolcs Nagy <nsz@port70.net>
Sat, 8 Jun 2013 13:49:12 +0000 (13:49 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Sat, 8 Jun 2013 13:49:12 +0000 (13:49 +0000)
this is a minor fix to increase the period of the obsolete rand_r a bit.
an include header in __rand48_step.c is fixed as well.

src/prng/__rand48_step.c
src/prng/rand_r.c

index 755b4f2..105f810 100644 (file)
@@ -1,5 +1,5 @@
 #include <stdlib.h>
-#include <inttypes.h>
+#include <stdint.h>
 
 uint64_t __rand48_step(unsigned short *xi, unsigned short *lc)
 {
index e96cfba..ef26dbd 100644 (file)
@@ -2,5 +2,5 @@
 
 int rand_r(unsigned *seed)
 {
-       return (*seed = *seed * 1103515245 + 12345) & 0x7fffffff;
+       return (*seed = *seed * 1103515245 + 12345)/2;
 }