Why isn't it better to just return pcg64_random(rng) * 0x1.0p-64? Then even if the high 11 bits of the value are zero, you still get a full mantissa's worth of randomness.
Even better, go back to the bit-hacking approach, and set all 52 mantissa bits to random values, and set the exponent to 0x3fe - __builtin_clz64(pcg64_random())? Then your exponent can go all the way down to -64, and you still have a full mantissa even at the low end.
I think the implicit one at the start of the mantissa is the issue here. IIUC these versions bias for 1.1abcdef * 2^g at the expense of 1.0hijklm * 2^n.
no subject
Date: 2023-06-24 07:58 (UTC)I think the implicit one at the start of the mantissa is the issue here.
IIUC these versions bias for 1.1abcdef * 2^g at the expense of 1.0hijklm * 2^n.