diff --git a/include/boost/math/special_functions/round.hpp b/include/boost/math/special_functions/round.hpp index 79afcb699..d3e661635 100644 --- a/include/boost/math/special_functions/round.hpp +++ b/include/boost/math/special_functions/round.hpp @@ -45,7 +45,7 @@ template inline bool is_representable(T x) { BOOST_MATH_STD_USING - return (floor(x) == x && x >= static_cast(0.0L) && x < ldexp(1.0, sizeof(TargetType) * CHAR_BIT)); + return (floor(x) == x && x >= static_cast(0.0L) && x < ldexp(static_cast(1.0L), sizeof(TargetType) * CHAR_BIT)); } template @@ -162,7 +162,8 @@ inline long long llround(const T& v, const Policy& pol) bool representable = boost::math::detail::is_representable(r); if (r < static_cast((std::numeric_limits::min)()) || - (return_val == LLONG_MAX && !representable)) + (return_val == (std::numeric_limits::max)() && !representable) || + r > static_cast((std::numeric_limits::max)())) { return static_cast(policies::raise_rounding_error("boost::math::llround<%1%>(%1%)", nullptr, v, static_cast(0), pol)); }