An easy way to generate a random float64 in [0,1) is by generating a uniformly random int in [0,2^52) and dividing it by 2^52. However, not all possible float64 values between 0 and 1 can be generated this way: if the value is lower than 2^-4 for example, the 4 last bits of the significand are always going to be 0.
How do you generate a uniformly random float64 such as every possible value has a chance of being returned?
Aucun commentaire:
Enregistrer un commentaire