dimanche 26 février 2017

std::uniform_int_distribution different behaviour on Mac and Windows

Code example:

#include <iostream>
#include <random>
using namespace std;

int main()
{
    mt19937 generator(0);
    uniform_int_distribution<int> distr(0, 100);

    for(auto i = 0; i < 10; ++i)
    {
         cout << distr(generator) << "\n";
    }
}

This code produces different numbers on Mac and Windows, but replacing uniform_int_distribution with uniform_real_distribution fixes that issue, and sequence generated is the same on both platforms.

My question is: why does it happen?




Aucun commentaire:

Enregistrer un commentaire