Boost logo

Boost :

From: Douglas Gregor (dgregor_at_[hidden])
Date: 2005-01-05 09:17:15


On Dec 31, 2004, at 10:51 AM, Jens Maurer wrote:
>> Looking at the source to uniform_real, the problem is obvious:
>> result_type operator()(Engine& eng) { return eng() * (_max - _min)
>> + _min; }
>
> Yes. Fixed.

It doesn't seem to be completely fixed, although it might be because I
am wrong. In the fix I'd sent, eng() - eng.min() would first be casted
to the result_type (a real type, of course), the we divide by eng.max()
- eng.min() and adjust to uniform_real's range. In the code in CVS, the
cast isn't performed until after the division. So when the engine
returns integer values (as linear_congruential does), we don't get
proper results. Is it wrong to use engines returning integer values
with uniform_real? If so, we should have a static assert in there.

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk