Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce rounding in rounded_arith_opp to fix incorrect behaviour. #4

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/boost/numeric/interval/rounded_arith.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ struct rounded_arith_opp: Rounding {
# define BOOST_UP_NEG(EXPR) return -this->force_rounding(EXPR)
template<class U> T conv_down(U const &v) { BOOST_UP_NEG(-v); }
template<class U> 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); }
Expand Down