On Wikipedia, I found the following random number generator:
#include <stdint.h>
/* The state must be seeded so that it is not everywhere zero. */
uint64_t s[ 2 ];
uint64_t next(void) {
uint64_t s1 = s[ 0 ];
const uint64_t s0 = s[ 1 ];
s[ 0 ] = s0;
s1 ^= s1 << 23;
return ( s[ 1 ] = ( s1 ^ s0 ^ ( s1 >> 17 ) ^ ( s0 >> 26 ) ) ) + s0;
}
Now, when implemented, (using a random seed for s[0] and s1), this works nicely, but outputs numbers like:
2318509732609079156, 5455176535758408500, 14446583927462861784, 3420274542024626201, etc.
My question now is: How can I transform these numbers to a uniform real distribution [0,1[, i.e. with 0 included and 1 excluded?