From 8372d0897cb0819284fbc97c837f86f88237e99d Mon Sep 17 00:00:00 2001 From: Gereon Kremer Date: Tue, 24 Jun 2014 16:58:26 +0200 Subject: [PATCH] Enforce rounding in rounded_arith_opp to fix incorrect behaviour. Using clang with optimizations leads to incorrect results under certain circumstances. --- include/boost/numeric/interval/rounded_arith.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/numeric/interval/rounded_arith.hpp b/include/boost/numeric/interval/rounded_arith.hpp index 8b2d9a7..a16da5a 100644 --- a/include/boost/numeric/interval/rounded_arith.hpp +++ b/include/boost/numeric/interval/rounded_arith.hpp @@ -92,10 +92,10 @@ struct rounded_arith_opp: Rounding { # define BOOST_UP_NEG(EXPR) return -this->force_rounding(EXPR) template T conv_down(U const &v) { BOOST_UP_NEG(-v); } template T conv_up (U const &v) { BOOST_UP(v); } - T add_down(const T& x, const T& y) { BOOST_UP_NEG((-x) - y); } + T add_down(const T& x, const T& y) { BOOST_UP_NEG(this->force_rounding(-x) - y); } T sub_down(const T& x, const T& y) { BOOST_UP_NEG(y - x); } - T mul_down(const T& x, const T& y) { BOOST_UP_NEG(x * (-y)); } - T div_down(const T& x, const T& y) { BOOST_UP_NEG(x / (-y)); } + T mul_down(const T& x, const T& y) { BOOST_UP_NEG(x * this->force_rounding(-y)); } + T div_down(const T& x, const T& y) { BOOST_UP_NEG(x / this->force_rounding(-y)); } T add_up (const T& x, const T& y) { BOOST_UP(x + y); } T sub_up (const T& x, const T& y) { BOOST_UP(x - y); } T mul_up (const T& x, const T& y) { BOOST_UP(x * y); }