I have a robust RNG that generates random 32-bit (unsigned) ints. As is probably well known, for metropolis MC simulation, a random number between 0 and 1 is needed to determine acceptance/rejection of a move, so I need to convert my 32-bit int into a (double-precision) floating point value.
My question is what is best practice for converting my 32-bit int into a float? I think I have the following two options:
(double) getRandomNumber() / 4294967295(2^32 - 1); range [0,1]
(double) getRandomNumber() / 4294967296(2^32); range [0,1)
The first option seems straightforward, with a range of [0,1]. There would be 2147483648 values in the range [0,0.5) and 2147483648 values in the range (0.5, 1].
In the second option, we have a range of [0,1), and 0.5 is represented exactly among the 2^32 possible floats. There is symmetry in that 50% of the values are in the range [0, .49999999977], and the other 50% are in the range [0.5, .99999999977].
Are there details in the int->double conversion that I am missing? What's standard practice for a range for probabilistic simulations of this type? Is it [0,1], (0,1], [0,1), or (0,1)? Or am I splitting hairs over a trivial matter?
Note I've read that division is less efficient than multiplication, so I do intend to precompute the reciprocal and multiply by that value instead in my actual implementation.