Boost logo

Boost :

From: Moore, Paul (paul.moore_at_[hidden])
Date: 2000-11-28 05:11:24

From: Moore, Paul
> To make my position explicit, I believe that
> rational<int> r1 = 0.1;
> rational<int> r2(1,10);
> should result in r1 == r2. If it does not, then I don't
> believe that an implicit conversion from double is
> appropriate - although maybe a function (which makes the
> issue explicit, say simplest_rational()) to do the job is
> appropriate.
> I will test the algorithms I have seen and find out if
> they make this equality happen. If any of them do, then no
> problem.

Good news. Dave Abrahams' algorithm correctly handles this case. More
specifically, it gives what I would expect for all fractions 1.0/n, 2.0/n,
3.0/n, 4.0/n where n is between 1 and 100. That's good enough for me!

Thanks, Dave. I'll code this up in C++ soonish. (Need to work out how to
trap overflow in C++...)


Boost list run by bdawes at, gregod at, cpdaniel at, john at