Index: rounded_arith.hpp =================================================================== --- rounded_arith.hpp (revision 42322) +++ rounded_arith.hpp (working copy) @@ -12,6 +12,10 @@ #include #include +#include +#include +#include +#include #include namespace boost { @@ -26,8 +30,8 @@ template struct rounded_arith_exact: Rounding { void init() { } - template T conv_down(U const &v) { return v; } - template T conv_up (U const &v) { return v; } + template T conv_down(U const &v) { return static_cast(v); } + template T conv_up (U const &v) { return static_cast(v); } T add_down (const T& x, const T& y) { return x + y; } T add_up (const T& x, const T& y) { return x + y; } T sub_down (const T& x, const T& y) { return x - y; } @@ -90,8 +94,14 @@ return r # define BOOST_UP(EXPR) return this->force_rounding(EXPR) # 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); } + template T conv_down(U const &v) + { + typedef typename mpl::eval_if< + is_integral, make_signed, mpl::identity >::type signed_type; + + BOOST_UP_NEG(static_cast(-static_cast(v))); + } + template T conv_up (U const &v) { BOOST_UP(static_cast(v)); } T add_down(const T& x, const T& y) { BOOST_UP_NEG((-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)); }