|
Boost : |
From: John (EBo) David (ebo_at_[hidden])
Date: 2000-11-21 15:15:00
When playing with the rationals some more I ran across another bug.
When initializing a rational from a floating point number, the value
is auto-casted to IntType and produces erroneous results. For
example:
int main ()
{
rational <int> tr;
td = 1.5; tr = td;
std::cout << "rational " << tr;
std::cout << " cast " << boost::rational_cast<double>(tr);
std::cout << " original double " << td << std::endl;
}
sets tr to be "1/1" and not "3/2"
Is it reasonable to provide a rational constructor and/or assignment
with a floating point argument?
Somewhat related to this is the operator>> definition. Isn't it
reasonable to assume that the user defined input should not have to be
redefined to use the "nnn/ddd" syntax, but to behave as expected when
accepting floating point input?
EBo --
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk