Random number generators discussion

Random number generators | www.agner.org

Generate ALL float numbers in RNG?
Author: Agner Date: 2004-06-19 09:54
Why don't you use one of the algorithms that give 52 or 63 bits resolution? Make sure your results are stored with double or long double precision so you don't loose information somewhere in your code. (Microsoft compilers don't support long double). With a resolution of 32 bits, you can get any value by chance within a reasonable time. With 52 bits or more you can not.

Even though it is possible to represent extremely small values 2^(-x) in a float or double or long double, it's not possible to store the value 1-2^(-x). A random number generator that can generate 2^(-x) but not 1-2^(-x) will obviously not have a perfect uniform distribution. Therefore, x is limited by the resolution, not the range.

 
thread Generate ALL float numbers in RNG? new - Hangzai Luo - 2004-06-16
last replythread Generate ALL float numbers in RNG? new - Agner - 2004-06-18
last replythread Generate ALL float numbers in RNG? new - Hangzai Luo - 2004-06-18
last reply Generate ALL float numbers in RNG? - Agner - 2004-06-19