On 2012-03-01 16:34:23 +, Ali Çehreli said:
Since there are also sub-normal values between 0 and T.min_normal, it
may make sense to use the range [T.min_normal, 1) and scale the result
from there. But I haven't tested whether the distinct values in that
range are equally distributed.
I g
On 2012-03-01 16:34:23 +, Ali Çehreli said:
I recommend reading this page:
http://dlang.org/d-floating-point.html
Thanks.
Especially the ASCII graph there is very interesting. The number of
distinct values between T.min_normal and 1 are equal to the distinct
values between 1 and T.
On 03/01/2012 02:52 AM, Magnus Lie Hetland wrote:
> What's the preferred way of generating a random floating-point number in
> the range of a given floating-point type? We have uniform!T() for
> integral types, but nothing similar for floats? And uniform(-real.max,
> real.max) (possibly tweaking t
On 2012-03-01 10:52:49 +, Magnus Lie Hetland said:
I could just use
uniform(cast(T) -1, cast(T) 1)*T.max
I guess (for some floating-point type T). Seems to work fine, at least.
Aaactually, not so much. The output here seems to get about the same
exponent as T.max. Which isn't all that
What's the preferred way of generating a random floating-point number
in the range of a given floating-point type? We have uniform!T() for
integral types, but nothing similar for floats? And uniform(-real.max,
real.max) (possibly tweaking the limits) seems to only return inf,
which isn't terrib