X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Fmath%2Fspecial_functions%2Ftrunc.hpp;h=8e515f3ea81c98a5306624a25f1efa138b9996c0;hp=49f933b34a10d933719fffbdc2ef4220225f25af;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/math/special_functions/trunc.hpp b/boost/math/special_functions/trunc.hpp index 49f933b..8e515f3 100644 --- a/boost/math/special_functions/trunc.hpp +++ b/boost/math/special_functions/trunc.hpp @@ -17,15 +17,16 @@ namespace boost{ namespace math{ template -inline T trunc(const T& v, const Policy& pol) +inline typename tools::promote_args::type trunc(const T& v, const Policy& pol) { BOOST_MATH_STD_USING + typedef typename tools::promote_args::type result_type; if(!(boost::math::isfinite)(v)) - return policies::raise_rounding_error("boost::math::trunc<%1%>(%1%)", 0, v, pol); - return (v >= 0) ? static_cast(floor(v)) : static_cast(ceil(v)); + return policies::raise_rounding_error("boost::math::trunc<%1%>(%1%)", 0, static_cast(v), static_cast(v), pol); + return (v >= 0) ? static_cast(floor(v)) : static_cast(ceil(v)); } template -inline T trunc(const T& v) +inline typename tools::promote_args::type trunc(const T& v) { return trunc(v, policies::policy<>()); } @@ -42,9 +43,10 @@ template inline int itrunc(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - T r = boost::math::trunc(v, pol); - if(fabs(r) > (std::numeric_limits::max)()) - return static_cast(policies::raise_rounding_error("boost::math::itrunc<%1%>(%1%)", 0, v, pol)); + typedef typename tools::promote_args::type result_type; + result_type r = boost::math::trunc(v, pol); + if((r > (std::numeric_limits::max)()) || (r < (std::numeric_limits::min)())) + return static_cast(policies::raise_rounding_error("boost::math::itrunc<%1%>(%1%)", 0, static_cast(v), 0, pol)); return static_cast(r); } template @@ -57,9 +59,10 @@ template inline long ltrunc(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - T r = boost::math::trunc(v, pol); - if(fabs(r) > (std::numeric_limits::max)()) - return static_cast(policies::raise_rounding_error("boost::math::ltrunc<%1%>(%1%)", 0, v, pol)); + typedef typename tools::promote_args::type result_type; + result_type r = boost::math::trunc(v, pol); + if((r > (std::numeric_limits::max)()) || (r < (std::numeric_limits::min)())) + return static_cast(policies::raise_rounding_error("boost::math::ltrunc<%1%>(%1%)", 0, static_cast(v), 0L, pol)); return static_cast(r); } template @@ -74,9 +77,10 @@ template inline boost::long_long_type lltrunc(const T& v, const Policy& pol) { BOOST_MATH_STD_USING - T r = boost::math::trunc(v, pol); - if(fabs(r) > (std::numeric_limits::max)()) - return static_cast(policies::raise_rounding_error("boost::math::lltrunc<%1%>(%1%)", 0, v, pol)); + typedef typename tools::promote_args::type result_type; + result_type r = boost::math::trunc(v, pol); + if((r > (std::numeric_limits::max)()) || (r < (std::numeric_limits::min)())) + return static_cast(policies::raise_rounding_error("boost::math::lltrunc<%1%>(%1%)", 0, v, static_cast(0), pol)); return static_cast(r); } template