
AMDG Sebastian Mach wrote:
today I found out that boost::random, at least the combination
boost::mt19937 rng(<seed>); typedef boost::uniform_int<int> dist_t; dist_t dist (<min>, <max>); boost::variate_generator< boost::mt19937&, dist_t
rand_ (rng, dist);
will give me different results depending on whether I use "g++ (Debian 4.3.2-1.1) 4.3.2" (with sizeof(long)=8) or "g++.exe (TDM-2 mingw32) 4.4.1" (with sizeof(long)=4).
This testcase: ++ #include
boost::mt19937 rng(1); typedef boost::uniform_int<int> dist_t; dist_t dist (0, 16); boost::variate_generator< boost::mt19937&, dist_t
rand_ (rng, dist);
int main () { for (int i=0; i<6; ++i) { std::cout << rand_() << std::endl; } } --
will print 16 8 1 6 0 12 with the 64bit variant variant, but 7 16 12 15 0 2 with the 32bit variant.
Is there a (preferably portable) way to ensure that they will be the same on all 32bit+ machines?
Otherwise this would be a real stopper to use boost::random for me, and I'd have to go back to libcoyotl's Mersenne Twister, which gives consistent results, upon which I really depend.
Are you using the same version of Boost for both? There were a bunch of bug fixes in uniform_int a few releases ago, which change the exact sequence produced. In Christ, Steven Watanabe