25 Nov
2013
25 Nov
'13
10:53 p.m.
AMDG On 11/25/2013 02:22 PM, Brian Budge wrote:
You can achieve what you want by generating a random number on [-1, 1] and multiplying it by the max float. I don't think that there is a *general* way to arrive at a uniform distribution of a range greater than max float by first generating a random number on [0, 1), so it's unlikely that the library can be "fixed" to achieve what you want.
It's really quite easy. if ( max - min == infinity ) { divisor = 2; min /= divisor; max /= divisor; } else { divisor = 1; } // compute a value in [min, max) as usual result *= divisor;
Another method would be to use double precision generation on the max float range, and then convert to float.
In Christ, Steven Watanabe