0

I'm trying to use boost for random number generation of a long double (on a 64bits machine).

At some point I use

rng = boost::mt19937();

However, compiler argues that on line 88 of boost/random/mersenne_twister.hpp,

x[i] = (1812433253UL * (x[i-1] ^ (x[i-1] >> (w-2))) + i) & mask;

there is an implicit conversion that shortens the 64-bit into a 32-bit value...

I didn't even specified if I want a long double or double... why is he arguing on that? Is because I'm using 64bits OS?

Is there any simple solution to this problem? I need a long double generator... xD

Thanks

Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121

1 Answers1

1

The mt19937 is 32bit. It is defined in the boost like

typedef mersenne_twister_engine<uint32_t,32,624,397,31,0x9908b0df,
11,0xffffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253> mt19937;

For 64bit is necessary to use mt19937_64.

megabyte1024
  • 8,482
  • 4
  • 30
  • 44
  • It didn't worked either: now complains here: line 99-100 of random/detail/large_arithmetic.hpp (boost version 1.49.0) – Jorge Leitao Mar 08 '12 at 15:39
  • Strange. I created a small test. There is no any warning or error message compiling on VC10. Here is a [link](http://ideone.com/XwHaL) to the source code. It is impossible to post the code in the comment. Out of limits. It is compiled without problems on VC10. The online compiler produces errors due to missing the `mt19937_64` class. Could you post your sample code which is not compilable? – megabyte1024 Mar 08 '12 at 18:25