Opened 8 years ago
Closed 7 years ago
#11054 closed Bugs (fixed)
Floating-point comparison of multiprecision values fails if expression template is on
Reported by: | Paul A. Bristow | Owned by: | Raffi Enficiaud |
---|---|---|---|
Milestone: | Boost 1.59.0 | Component: | test |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | test multiprecision expression template | Cc: | raffi.enficiaud@… |
Description
Floating-point comparison of multiprecision values fails if expression template option is on (which is the default for example with
boost::multiprecision::cpp_bin_float_50; typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<50>, boost::multiprecision::et_on> cpp_bin_float_50_et_on; // et_on is default so is same as cpp_bin_float_50.)
The error appears inside Boost.test floating_point_comparision.hpp at an apparently impossible place fpc_detail::fpt_abs.
The actual problem is in class close_at_tolerance operator() line 204
FPT diff = fpc_detail::fpt_abs(left - right);
in order to allow use of expression templates, it is necessary to cast the variable diff to the FPT explicitly, thus:
FPT diff = fpc_detail::fpt_abs( static_cast<FPT>(left - right) );
I can provide an explicit test for this, but it seems such a trivial change.
This change is vital to allow Boost.Test to be used fully with Boost.Multiprecision.
Change History (5)
comment:1 by , 8 years ago
Owner: | changed from | to
---|
comment:2 by , 8 years ago
comment:3 by , 8 years ago
Status: | new → assigned |
---|
comment:4 by , 8 years ago
Version: | Boost 1.58.0 → Boost 1.59.0 |
---|
merged to develop 47829d34593d9ca52de0d0a8b798b128f9ffa71f
comment:5 by , 7 years ago
Milestone: | To Be Determined → Boost 1.59.0 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
From the email exchanges, seems to work on the branch local/doc_floating_point_fixes. What remains for the issue is to have a proper unit test on this for multiprecision.