|
|
|
|
|
by strainer
2692 days ago
|
|
Possibly we could generate a random number at the subnormal range (with 0 exponent) then multiply by 0.99999~ divided by the greatest possible 0 exponent number. uint64 x = rand64()&0x000F'FFFF'FFFF'FFFF
return *(double*)&x * 4.49423283715579e+307
I tweaked the multiplier as high as possible without producing 1, but there might be a fraction of a bit bias introduced by the multiplication compared to the method of subtracting 1 from 1-2 range.edit:
That multiplier seems to be essentially 2^1022, in which case there may be no quantization noise possible in multiplying by it. It may simply cause the exponent to be increased and the result normalised. |
|