Theo de Raadt wrote: > 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?
s/xseed/rseed/g -- Alex