Alexander Nasonov <al...@yandex.ru> wrote: > Ingo Schwarze wrote: > > 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. > > I looked at the code too and I have some comments. > > > More generally, the function returns a uniform distribution of > > numbers from the set {2^-48 * n | n integer and 0 <= n < 2^48}. > > You don't need three ldexp calls to compose 2^-48 * n: > > uint64_t n = (uint64_t)xseed[2] << 32 | xseed[1] << 16 | xseed[0]; > return ldexp((double)n, -48);
xseed? Yikes. That version of the code is not reached in OpenBSD unless __rand48_deterministic is set, which means srand48_deterministic or seed48_deterministic or lcong48_deterministic were called... We've seen noone going out of their way, so why touch that code...