3 ms·
Small correction: Assuming "uniform" to mean the uniform distribution, there are actually 2^62 - 2^52 possible binary64 values in the [0, 1) range with differin
by lifthrasiir 4y ago
Small correction: Assuming "uniform" to mean the uniform distribution, there are actually 2^62 - 2^52 possible binary64 values in the [0, 1) range with differing probabilities. So the maximally correct implementation can't generate just a single 32-bit or 64-bit integer to generate one fp number as some numbers would have a probability much smaller than 2^64. Of course this is not how they are typically generated, nor this improves the uniformity of formulas like `Math.random() * range`.
- Dylan16807 4y ago> Assuming "uniform" to mean the uniform distribution Well, yes, but a discrete/integer-ish version. Every number is equidistant and equally likely.