Boost logo

Boost :

From: Moore, Paul (paul.moore_at_[hidden])
Date: 2002-02-11 04:33:00


From: "vesa_karvonen" <vesa_karvonen_at_[hidden]>
> --- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
> > The definition of operator /= for class template
> > rational does not handle self divisions (as in r /=
> > r;) correctly:
>
> Whoever fixes this should make sure that a regression test is added
> to test self division. These kind of things are likely to be broken
> by "optimizations" or "simplifications" accidentaly.

Good point. I will look at adding such a test

> > This code should be changed to:
> >
> > IntType rnum = r.num;
> > num = (num/gcd1) * (r.den/gcd2);
> > den = (den/gcd2) * (rnum/gcd1);
>
> The above is likely to improve the efficiency of the code when
> IntType is a built-in type. It effectively tells the compiler that it
> can cache rnum in a register.

Agreed. Can someone put this change into the code? I will add a test soon.

Paul.


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