Boost logo

Boost Users :

From: rupp_at_[hidden]
Date: 2004-02-13 04:49:21


I have either overlooked something basic or found a bug in the random library:

boost::mt19937 engine_;
double result_ = boost::uniform_real<double>(0., 1.) (engine_);
std::cout << result_ << std::endl;
assert ( (0. <= result_) && (result_ < 1.) );

results in

4.29093e+09
test_boost: test/test_boost.cpp:17: void test_random (): Assertion `(0. <=
result_) && (result_ < 1.)' failed.
Abort

Although the documentation says "The current implementation is buggy, because it
may not fill all of the mantissa with random bits." IMHO this is worse than
that: I expected the result to satisfy min <= result < max.

I'm using boost 1.31.0 and g++ 2.96 as well as g++ 3.3.2 (identical results) on
Red Hat Linux.

I hope that either someone can explain me my mistake or fix the bug.

Matthias Rupp


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net