I have a RNG function xorshift128plus that takes a Xorshift128PlusKey:
/**
* \brief Keys for scalar xorshift128. Must be non-zero.
* These are modified by xorshift128plus.
*/
struct Xorshift128PlusKey
{
uint64_t s1;
uint64_t s2;
};
/**
* \brief Return a new 64-bit random number.
*/
uint64_t xorshift128plus(Xorshift128PlusKey* key);
I would like to seed my RNG using rdtsc (processor time stamp). The problem is that the __rdtsc intrinsic under msvc returns a 64 bit unsigned integer and the seed must be a 32 bit unsigned integer. What is the best way to convert the rdtsc to a seed while preserving randomness. The conversion must be as fast as possible.
I can't use the std lib or boost. (It's for a game engine)
Aucun commentaire:
Enregistrer un commentaire