From 97cd1ea0ea304daa535ae41c6f732c9b05a705f5 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sat, 28 Feb 2015 19:31:05 +0000 Subject: [PATCH] Change not to use cstdfloat as that header may not actually define any types! --- include/boost/math/concepts/real_concept.hpp | 2 +- .../boost/math/concepts/std_real_concept.hpp | 2 +- include/boost/math/tools/big_constant.hpp | 39 +++++++++++++------ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/include/boost/math/concepts/real_concept.hpp b/include/boost/math/concepts/real_concept.hpp index 2267271a0..2b105e6c8 100644 --- a/include/boost/math/concepts/real_concept.hpp +++ b/include/boost/math/concepts/real_concept.hpp @@ -328,7 +328,7 @@ namespace tools { template <> -inline concepts::real_concept make_big_value(boost::floatmax_t val, const char* , mpl::false_ const&, mpl::false_ const&) +inline concepts::real_concept make_big_value(boost::math::tools::largest_float val, const char* , mpl::false_ const&, mpl::false_ const&) { return val; // Can't use lexical_cast here, sometimes it fails.... } diff --git a/include/boost/math/concepts/std_real_concept.hpp b/include/boost/math/concepts/std_real_concept.hpp index b4f75bcad..c565ce377 100644 --- a/include/boost/math/concepts/std_real_concept.hpp +++ b/include/boost/math/concepts/std_real_concept.hpp @@ -342,7 +342,7 @@ namespace tools { template <> -inline concepts::std_real_concept make_big_value(boost::floatmax_t val, const char*, mpl::false_ const&, mpl::false_ const&) +inline concepts::std_real_concept make_big_value(boost::math::tools::largest_float val, const char*, mpl::false_ const&, mpl::false_ const&) { return val; // Can't use lexical_cast here, sometimes it fails.... } diff --git a/include/boost/math/tools/big_constant.hpp b/include/boost/math/tools/big_constant.hpp index 423cc1b63..375cea924 100644 --- a/include/boost/math/tools/big_constant.hpp +++ b/include/boost/math/tools/big_constant.hpp @@ -12,31 +12,48 @@ #include #endif #include -#include namespace boost{ namespace math{ namespace tools{ template -inline BOOST_CONSTEXPR_OR_CONST T make_big_value(boost::floatmax_t v, const char*, mpl::true_ const&, mpl::false_ const&) +struct numeric_traits : public std::numeric_limits< T > {}; + +#ifdef BOOST_MATH_USE_FLOAT128 +typedef __float128 largest_float; +#define BOOST_MATH_LARGEST_FLOAT_C(x) x##Q +template <> +struct numeric_traits<__float128> +{ + static const int digits = 113; + static const int digits10 = 34; + static const int max_exponent = 16384; +}; +#else +typedef long double largest_float; +#define BOOST_MATH_LARGEST_FLOAT_C(x) x##L +#endif + +template +inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, mpl::true_ const&, mpl::false_ const&) { return static_cast(v); } template -inline BOOST_CONSTEXPR_OR_CONST T make_big_value(boost::floatmax_t v, const char*, mpl::true_ const&, mpl::true_ const&) +inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, mpl::true_ const&, mpl::true_ const&) { return static_cast(v); } #ifndef BOOST_MATH_NO_LEXICAL_CAST template -inline T make_big_value(boost::floatmax_t, const char* s, mpl::false_ const&, mpl::false_ const&) +inline T make_big_value(largest_float, const char* s, mpl::false_ const&, mpl::false_ const&) { return boost::lexical_cast(s); } #endif template -inline BOOST_CONSTEXPR const char* make_big_value(boost::floatmax_t, const char* s, mpl::false_ const&, mpl::true_ const&) +inline BOOST_CONSTEXPR const char* make_big_value(largest_float, const char* s, mpl::false_ const&, mpl::true_ const&) { return s; } @@ -46,20 +63,20 @@ inline BOOST_CONSTEXPR const char* make_big_value(boost::floatmax_t, const char* // #define BOOST_MATH_BIG_CONSTANT(T, D, x)\ boost::math::tools::make_big_value(\ - BOOST_FLOATMAX_C(x), \ + BOOST_MATH_LARGEST_FLOAT_C(x), \ BOOST_STRINGIZE(x), \ - mpl::bool_< (is_convertible::value) && \ - ((D <= std::numeric_limits::digits) \ + mpl::bool_< (is_convertible::value) && \ + ((D <= boost::math::tools::numeric_traits::digits) \ || is_floating_point::value \ - || (std::numeric_limits::is_specialized && \ - (std::numeric_limits::digits10 <= std::numeric_limits::digits10))) >(), \ + || (boost::math::tools::numeric_traits::is_specialized && \ + (boost::math::tools::numeric_traits::digits10 <= boost::math::tools::numeric_traits::digits10))) >(), \ boost::is_convertible()) // // For constants too huge for any conceivable long double (and which generate compiler errors if we try and declare them as such): // #define BOOST_MATH_HUGE_CONSTANT(T, D, x)\ boost::math::tools::make_big_value(0.0L, BOOST_STRINGIZE(x), \ - mpl::bool_::value || (std::numeric_limits::is_specialized && std::numeric_limits::max_exponent <= std::numeric_limits::max_exponent && std::numeric_limits::digits <= std::numeric_limits::digits)>(), \ + mpl::bool_::value || (boost::math::tools::numeric_traits::is_specialized && boost::math::tools::numeric_traits::max_exponent <= boost::math::tools::numeric_traits::max_exponent && boost::math::tools::numeric_traits::digits <= boost::math::tools::numeric_traits::digits)>(), \ boost::is_convertible()) }}} // namespaces