X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Fmath%2Ftools%2Fbig_constant.hpp;fp=boost%2Fmath%2Ftools%2Fbig_constant.hpp;h=c5654b1aab1eb461d332201375cb202fe843d3c4;hp=0000000000000000000000000000000000000000;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/math/tools/big_constant.hpp b/boost/math/tools/big_constant.hpp new file mode 100644 index 0000000..c5654b1 --- /dev/null +++ b/boost/math/tools/big_constant.hpp @@ -0,0 +1,67 @@ + +// Copyright (c) 2011 John Maddock +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_MATH_TOOLS_BIG_CONSTANT_HPP +#define BOOST_MATH_TOOLS_BIG_CONSTANT_HPP + +#include +#ifndef BOOST_MATH_NO_LEXICAL_CAST +#include +#endif +#include + +namespace boost{ namespace math{ + +namespace tools{ + +template +inline BOOST_CONSTEXPR_OR_CONST T make_big_value(long double v, const char*, mpl::true_ const&, mpl::false_ const&) +{ + return static_cast(v); +} +template +inline BOOST_CONSTEXPR_OR_CONST T make_big_value(long double 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(long double, const char* s, mpl::false_ const&, mpl::false_ const&) +{ + return boost::lexical_cast(s); +} +#endif +template +inline BOOST_CONSTEXPR const char* make_big_value(long double, const char* s, mpl::false_ const&, mpl::true_ const&) +{ + return s; +} + +// +// For constants which might fit in a long double (if it's big enough): +// +#define BOOST_MATH_BIG_CONSTANT(T, D, x)\ + boost::math::tools::make_big_value(\ + BOOST_JOIN(x, L), \ + BOOST_STRINGIZE(x), \ + mpl::bool_< (is_convertible::value) && \ + ((D <= std::numeric_limits::digits) \ + || is_floating_point::value \ + || (std::numeric_limits::is_specialized && \ + (std::numeric_limits::digits10 <= std::numeric_limits::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)>(), \ + boost::is_convertible()) + +}}} // namespaces + +#endif +