
On 2006-03-17, John Maddock <john@johnmaddock.co.uk> wrote:
I seriously hope I'm doing something wrong here, but the last 20 bits in a double returned from uniform_real appear to always be zero. Is this by design? I really hope not!
Take a look at the implementation of uniform_real - you'll see that it does: template<class Engine> result_type operator()(Engine& eng) { return static_cast<result_type>(eng() - eng.min()) / static_cast<result_type>(eng.max() - eng.min()) * (_max - _min) + _min; } (with suitable removal of min/max protection macros.) Since the engine is a integer based generator (probably 32 bits on most 32 bit platforms) there is no way it can generate more than 32 bits of randomness with this implementation. Hence the 20 bits of zeroes at the end of the double. What it really needs to do is detect that the engine type hasn't got enough bits and call the engine repeatedly until it has filled the result_type up... phil -- change name before "@" to "phil" for email