I need to generate roughly 700 uniformly distributed uint64 numbers on program startup. There are some external parts that rely on these numbers being the same every time the program is booted up. I could, of course, generate these numbers only once and then hardcode them into a large array, and use that. However, i would like to avoid that, if possible.
What i'm doing right now is having a fixed seed value and relying on the mt19937 generator to generate the exact same sequence every time.
auto seed = 2079078781365792;
std::mt19937_64 mt(seed);
std::uniform_int_distribution<uint64_t> distribution;
auto value = distribution(mt);
This works great for me now. But i'm wondering, if this is going to work with different compilers/different platforms, to always provide the user with the exact same sequence of numbers? Is it possible that the mersenne twister/uniform distribution is implemented slightly differently in such a way that would generate different sequence despite the same seed?
Aucun commentaire:
Enregistrer un commentaire