[Bug libstdc++/44653] A uniform_real random distribution produces invalid floating-point random numbers
dchichkov at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 24 09:54:00 GMT 2010
------- Comment #1 from dchichkov at gmail dot com 2010-06-24 09:53 -------
Update. Following code produces the correct value:
#include <functional>
#include <random>
#include <iostream>
int main()
{
typedef std::mt19937 eng_t;
typedef std::uniform_real<double> dist_t;
typedef std::variate_generator <eng_t, dist_t > gen_t;
eng_t eng;
dist_t dist(0.0, 1.0);
gen_t gen(eng, dist);
std::cout << gen() << std::endl;
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44653
More information about the Gcc-bugs
mailing list