Hi,
I'm having trouble generating uniform random doubles in [0,1) with
arc4random. In games, the snippet:
(double) arc4random() / (UINT32_MAX + 1.0)
crops up multiple times, but that isn't utilising the full precision of
a double. If you do the equivalent with a 64bit random integer:
(double) ((uint64_t) arc4random() << 32 | arc4random()) / (UINT64_MAX +
1.0)
then I can still see two issues. Firstly, we are now putting too much
precision into a double which is going to add slight bias when it
rounds. Secondly, `UINT64_MAX + 1.0` probably isn't going to give us
what we want because of floating point precision.
Any ideas?
Mike