Date: 2000-11-28 05:34:06
--- In boost_at_[hidden], "Moore, Paul" <paul.moore_at_u...> wrote:
> 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 agree, that r1 should be the same as r2. But what I was wondering
about is the following: When I give my compiler the following code
cout << r1;
it prints '0.1' - which is what I *mean*, not the exact value of r1!
Therefore, some algorithms to handle the conversion must be already
included in 'cout'. If we supply a constructor from a string, we won't
have problems with this those conversion problems:
rational<int> r3 = "0.1";
The constructor for 'double' would than look like this:
rational<int> r4 = lexical_cast<string>( 0.1 );
or you could allow a special version taking the double as a native
value. The problem I see is efficiency..
Just an idea...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk