#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>
{
#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>
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;
}
} // 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);
{
#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;
#endif
}
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
template <class T>
inline T epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
{
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());
}