(1300 775 775) office | +61 419201410 mobile
SQL Down Under | Web: https://sqldownunder.com<https://sqldownunder.com/> |
About Greg: https://about.me/greg.low
From: Greg Keogh
Sent: Tuesday, 5 July 2022 8:58 AM
To: Dr Greg Low
Cc: ozDotNet
Subject: Re: 53-bit double
I might have
>
> I might have missed it earlier Greg but was the actual problem that this
> helps with? I was intrigued by the underlying problem.
>
I didn't express myself clearly originally. I was trying to convert a
64-bit random integer into a double and guarantee that all possible 2^53
floating values in
About Greg: https://about.me/greg.low
From: Greg Keogh via ozdotnet
Sent: Tuesday, 5 July 2022 8:37 AM
To: ozDotNet
Cc: Greg Keogh
Subject: Re: 53-bit double
uint u1 = [32 random bits];
uint u2 = [32 random bits];
uint a = u1 >> 5, b = u2 >> 6;
return (a * 67108864.0 + b) * (1.0 /
>
> uint u1 = *[32 random bits]*;
> uint u2 = *[32 random bits]*;
> uint a = u1 >> 5, b = u2 >> 6;
> return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);
>
> Can anyone explain this magic? Is this correct?
>
This bit trick is no longer important to decode. I was trying to figure out
how to