Hi,
Alexander Nasonov wrote on Fri, Dec 20, 2019 at 08:33:40PM +0000:
> [email protected] wrote:
>> Clarify that drand48 returns values not including 1.0.
> It's not clear from the documentation whether drand48 can generate
> a denormal number. If it can't, you can exclude 0.0 because it's
> a denormal ;-)
Looking at our code in lib/libc/stdlib/drand48.c, i conclude that
drand48(3) does return 0.0 with a probability of 2^-48.
More generally, the function returns a uniform distribution of
numbers from the set {2^-48 * n | n integer and 0 <= n < 2^48}.
Talking about loading bits into the mantissa and adjusting the
exponent feels mildly confusing, given that the distribution is
simply uniform over a fixed finite set. I'm not sending a patch
because i never looked at how floating point representation works
internally, so i would likely only make matters worse.
Yours,
Ingo