cstdfloat_limits.hpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright Christopher Kormanyos 2014.
  3. // Copyright John Maddock 2014.
  4. // Copyright Paul Bristow 2014.
  5. // Distributed under the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt
  7. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // Implement quadruple-precision std::numeric_limits<> support.
  10. #ifndef _BOOST_CSTDFLOAT_LIMITS_2014_01_09_HPP_
  11. #define _BOOST_CSTDFLOAT_LIMITS_2014_01_09_HPP_
  12. #include <boost/math/cstdfloat/cstdfloat_types.hpp>
  13. #if defined(BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T) && defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT)
  14. #include <limits>
  15. // Define the name of the global quadruple-precision function to be used for
  16. // calculating quiet_NaN() in the specialization of std::numeric_limits<>.
  17. #if defined(BOOST_INTEL)
  18. #define BOOST_CSTDFLOAT_FLOAT128_SQRT __sqrtq
  19. #elif defined(__GNUC__)
  20. #define BOOST_CSTDFLOAT_FLOAT128_SQRT sqrtq
  21. #endif
  22. // Forward declaration of the quadruple-precision square root function.
  23. extern "C" boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT128_SQRT(boost::math::cstdfloat::detail::float_internal128_t) throw();
  24. namespace std
  25. {
  26. template<>
  27. class numeric_limits<boost::math::cstdfloat::detail::float_internal128_t>
  28. {
  29. public:
  30. BOOST_STATIC_CONSTEXPR bool is_specialized = true;
  31. static boost::math::cstdfloat::detail::float_internal128_t (min) () BOOST_NOEXCEPT { return BOOST_CSTDFLOAT_FLOAT128_MIN; }
  32. static boost::math::cstdfloat::detail::float_internal128_t (max) () BOOST_NOEXCEPT { return BOOST_CSTDFLOAT_FLOAT128_MAX; }
  33. static boost::math::cstdfloat::detail::float_internal128_t lowest() BOOST_NOEXCEPT { return -(max)(); }
  34. BOOST_STATIC_CONSTEXPR int digits = 113;
  35. BOOST_STATIC_CONSTEXPR int digits10 = 33;
  36. BOOST_STATIC_CONSTEXPR int max_digits10 = 36;
  37. BOOST_STATIC_CONSTEXPR bool is_signed = true;
  38. BOOST_STATIC_CONSTEXPR bool is_integer = false;
  39. BOOST_STATIC_CONSTEXPR bool is_exact = false;
  40. BOOST_STATIC_CONSTEXPR int radix = 2;
  41. static boost::math::cstdfloat::detail::float_internal128_t epsilon () { return BOOST_CSTDFLOAT_FLOAT128_EPS; }
  42. static boost::math::cstdfloat::detail::float_internal128_t round_error() { return BOOST_FLOAT128_C(0.5); }
  43. BOOST_STATIC_CONSTEXPR int min_exponent = -16381;
  44. BOOST_STATIC_CONSTEXPR int min_exponent10 = static_cast<int>((min_exponent * 301L) / 1000L);
  45. BOOST_STATIC_CONSTEXPR int max_exponent = +16384;
  46. BOOST_STATIC_CONSTEXPR int max_exponent10 = static_cast<int>((max_exponent * 301L) / 1000L);
  47. BOOST_STATIC_CONSTEXPR bool has_infinity = true;
  48. BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = true;
  49. BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
  50. BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
  51. BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
  52. static boost::math::cstdfloat::detail::float_internal128_t infinity () { return BOOST_FLOAT128_C(1.0) / BOOST_FLOAT128_C(0.0); }
  53. static boost::math::cstdfloat::detail::float_internal128_t quiet_NaN () { return ::BOOST_CSTDFLOAT_FLOAT128_SQRT(BOOST_FLOAT128_C(-1.0)); }
  54. static boost::math::cstdfloat::detail::float_internal128_t signaling_NaN() { return BOOST_FLOAT128_C(0.0); }
  55. static boost::math::cstdfloat::detail::float_internal128_t denorm_min () { return BOOST_FLOAT128_C(0.0); }
  56. BOOST_STATIC_CONSTEXPR bool is_iec559 = true;
  57. BOOST_STATIC_CONSTEXPR bool is_bounded = false;
  58. BOOST_STATIC_CONSTEXPR bool is_modulo = false;
  59. BOOST_STATIC_CONSTEXPR bool traps = false;
  60. BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
  61. BOOST_STATIC_CONSTEXPR float_round_style round_style = round_to_nearest;
  62. };
  63. } // namespace std
  64. #endif // Not BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT (i.e., the user would like to have libquadmath support)
  65. #endif // _BOOST_CSTDFLOAT_LIMITS_2014_01_09_HPP_