vendredi 17 février 2023

Bitwise convert a random to FP64 with vlues between 0 and 1

I am writing a laboratory data processing script in Excel VBA. The idea is acquiring improved random numbers using RtlGenRandom. The difficulty is that RtlGenRandom seeds the byte array in a byte-wise manner. So for reducing the time and keeping the "randomish" distribution, I want to apply a bitwise mask for reducing the number to [0 to 1] values. Below is a mnemonic explanation what I want to do regardless of exact implementation:

longlong buffer
longlong mask
double rand_val
RtlGenRandom(buffer,8)
buffer=not(buffer or mask)
rand_val=typeless_copy(rand_val, buffer)

So I got a little lost what should be the value of that mask for the said truncation of valuses. Bitwise, or in 0xHex.

I thought, it should be 0xC000 0000 0000 0000, but something is wrong.




Aucun commentaire:

Enregistrer un commentaire