|
Boost : |
Subject: Re: [boost] [Review Request] Multiprecision Arithmetic Library
From: Christopher Kormanyos (e_float_at_[hidden])
Date: 2012-04-15 05:58:39
>>All tests except one pass with my refactored code.
>>Unfortunately, test_float_io.cpp fails when round tripping
>>from cpp_dec_float to a string with a large exponent back
>>to cpp_dec_float.
> OK good, I'd like that to work if possible, it seems like something users
> would want and/or expect?
What I can't figure out, though, is if a floating-point
type actually *should* round-trip back from a string in
scientific format with (max_digits10 + 1) precision.
Remember, that kind of string has (max_digits10 + 1)
after the decimal point plus one digit in the mantissa.
That would be like asking 8-byte double to be exact
when round-tripping with 17 decimal digits of precision
since the scientific notation would have 1+16 decimal digits.
Would a *relative-to-epsilon* kind of test, maybe, be more
correct (correct-er) in test_float_io.cpp? Is *correcter* a word
other than the one who corrects?
template <class T>
void do_round_trip(const T& val, std::ios_base::fmtflags f)
{
std::stringstream ss;
ss.flags(f);
ss << std::setprecision(std::numeric_limits<T>::digits10)
<< val;
T new_val = ss.str();
BOOST_CHECK_CLOSE(new_val, val, std::numeric_limits<T>::epsilon());
new_val = val.str(0, f);
BOOST_CHECK_CLOSE(new_val, val, std::numeric_limits<T>::epsilon());
}
Best regards, Chris.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk