]> git.donarmstrong.com Git - rsem.git/blobdiff - boost/math/tools/precision.hpp
Updated boost to v1.55.0
[rsem.git] / boost / math / tools / precision.hpp
index e7695e92a5a92ca3c3afb79e3b6d015fdfd8958b..66d2754278e98708c95da1827b48cb9a80f067a4 100644 (file)
@@ -18,8 +18,6 @@
 #include <boost/mpl/if.hpp>
 #include <boost/math/policies/policy.hpp>
 
-#include <iostream>
-#include <iomanip>
 // These two are for LDBL_MAN_DIG:
 #include <limits.h>
 #include <math.h>
@@ -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<T>::is_specialized);
+   BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::radix == 2 || ::std::numeric_limits<T>::radix == 10);
 #else
    BOOST_ASSERT(::std::numeric_limits<T>::is_specialized);
+   BOOST_ASSERT(::std::numeric_limits<T>::radix == 2 || ::std::numeric_limits<T>::radix == 10);
 #endif
-   return std::numeric_limits<T>::digits;
+   return std::numeric_limits<T>::radix == 2 
+      ? std::numeric_limits<T>::digits
+      : ((std::numeric_limits<T>::digits + 1) * 1000L) / 301L;
 }
 
 template <class T>
@@ -145,7 +147,7 @@ inline T log_min_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_T
    BOOST_ASSERT(::std::numeric_limits<T>::is_specialized);
 #endif
    BOOST_MATH_STD_USING
-   static const T val = log((std::numeric_limits<T>::max)());
+   static const T val = log((std::numeric_limits<T>::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 <class T>
 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<T>::max_exponent == 128
+      (std::numeric_limits<T>::radix == 2) &&
+      (std::numeric_limits<T>::max_exponent == 128
       || std::numeric_limits<T>::max_exponent == 1024
-      || std::numeric_limits<T>::max_exponent == 16384,
-      mpl::int_<std::numeric_limits<T>::max_exponent>,
+      || std::numeric_limits<T>::max_exponent == 16384),
+      mpl::int_<(std::numeric_limits<T>::max_exponent > INT_MAX ? INT_MAX : static_cast<int>(std::numeric_limits<T>::max_exponent))>,
       mpl::int_<0>
    >::type tag_type;
    BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::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<T>::max_exponent == 128
+      (std::numeric_limits<T>::radix == 2) &&
+      (std::numeric_limits<T>::max_exponent == 128
       || std::numeric_limits<T>::max_exponent == 1024
-      || std::numeric_limits<T>::max_exponent == 16384,
-      mpl::int_<std::numeric_limits<T>::max_exponent>,
+      || std::numeric_limits<T>::max_exponent == 16384),
+      mpl::int_<(std::numeric_limits<T>::max_exponent > INT_MAX ? INT_MAX : static_cast<int>(std::numeric_limits<T>::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 <class T>
 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 <class T>
 inline T root_epsilon()
 {
-   typedef mpl::int_<std::numeric_limits<T>::digits> tag_type;
+   typedef mpl::int_< (::std::numeric_limits<T>::radix == 2) ? std::numeric_limits<T>::digits : 0> tag_type;
    return detail::root_epsilon_imp(static_cast<T const*>(0), tag_type());
 }
 
 template <class T>
 inline T forth_root_epsilon()
 {
-   typedef mpl::int_<std::numeric_limits<T>::digits> tag_type;
+   typedef mpl::int_< (::std::numeric_limits<T>::radix == 2) ? std::numeric_limits<T>::digits : 0> tag_type;
    return detail::forth_root_epsilon_imp(static_cast<T const*>(0), tag_type());
 }