News for hackers. Stuff that matters.
Re:There's Math.random(), and then there's Math.random() (2015) by fanf2 on Wednesday November 08, 2023 @01:09PM (#38194412)
My favourite implementation is

    double random_double(rng_t *rng) {
        return((double)(random_uint64(rng) >> 11) * 0x1.0p-53);
    }
It has the advantage of not needing bit_cast (which C lacks) and has 53 instead of 52 bits of randomness.

There are no comments on this comment yet.