X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Fmath%2Ftools%2Fprecision.hpp;h=66d2754278e98708c95da1827b48cb9a80f067a4;hp=e7695e92a5a92ca3c3afb79e3b6d015fdfd8958b;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/math/tools/precision.hpp b/boost/math/tools/precision.hpp index e7695e9..66d2754 100644 --- a/boost/math/tools/precision.hpp +++ b/boost/math/tools/precision.hpp @@ -18,8 +18,6 @@ #include #include -#include -#include // These two are for LDBL_MAN_DIG: #include #include @@ -45,10 +43,14 @@ inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2 || ::std::numeric_limits::radix == 10); #else BOOST_ASSERT(::std::numeric_limits::is_specialized); + BOOST_ASSERT(::std::numeric_limits::radix == 2 || ::std::numeric_limits::radix == 10); #endif - return std::numeric_limits::digits; + return std::numeric_limits::radix == 2 + ? std::numeric_limits::digits + : ((std::numeric_limits::digits + 1) * 1000L) / 301L; } template @@ -145,7 +147,7 @@ inline T log_min_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_T BOOST_ASSERT(::std::numeric_limits::is_specialized); #endif BOOST_MATH_STD_USING - static const T val = log((std::numeric_limits::max)()); + static const T val = log((std::numeric_limits::min)()); return val; } @@ -177,15 +179,21 @@ inline T epsilon(const mpl::false_& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T)) } // namespace detail +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4309) +#endif + template inline T log_max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS typedef typename mpl::if_c< - std::numeric_limits::max_exponent == 128 + (std::numeric_limits::radix == 2) && + (std::numeric_limits::max_exponent == 128 || std::numeric_limits::max_exponent == 1024 - || std::numeric_limits::max_exponent == 16384, - mpl::int_::max_exponent>, + || std::numeric_limits::max_exponent == 16384), + mpl::int_<(std::numeric_limits::max_exponent > INT_MAX ? INT_MAX : static_cast(std::numeric_limits::max_exponent))>, mpl::int_<0> >::type tag_type; BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); @@ -203,10 +211,11 @@ inline T log_min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS typedef typename mpl::if_c< - std::numeric_limits::max_exponent == 128 + (std::numeric_limits::radix == 2) && + (std::numeric_limits::max_exponent == 128 || std::numeric_limits::max_exponent == 1024 - || std::numeric_limits::max_exponent == 16384, - mpl::int_::max_exponent>, + || std::numeric_limits::max_exponent == 16384), + mpl::int_<(std::numeric_limits::max_exponent > INT_MAX ? INT_MAX : static_cast(std::numeric_limits::max_exponent))>, mpl::int_<0> >::type tag_type; @@ -220,6 +229,10 @@ inline T log_min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) #endif } +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + template inline T epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) { @@ -303,14 +316,14 @@ inline T forth_root_epsilon_imp(const T*, const Tag&) template inline T root_epsilon() { - typedef mpl::int_::digits> tag_type; + typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; return detail::root_epsilon_imp(static_cast(0), tag_type()); } template inline T forth_root_epsilon() { - typedef mpl::int_::digits> tag_type; + typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; return detail::forth_root_epsilon_imp(static_cast(0), tag_type()); }