On 2012-03-01 16:34:23 +0000, 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.max
.
Ah -- right.
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.
Hm. Seems reasonable.
But I haven't tested whether the distinct values in that range are
equally distributed.
At the moment, I'm just using this for test-case generation, so
anything close to a reasonable approximation is fine :)
However: Perhaps it would be useful with a uniform!real() or the like
in Phobos? Or is that (because of the vagaries of FP) a weird thing to
do, inviting misunderstandings and odd behavior? Perhaps it's been left
out for a reason? (Sounds sort of likely ;-)
--
Magnus Lie Hetland
http://hetland.org