1// (C) Copyright John Maddock 2021.
2// Use, modification and distribution are subject to the
3// Boost Software License, Version 1.0. (See accompanying file
4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5//
6// We deliberately use assert in here:
7//
8
9#ifndef BOOST_MP_DETAIL_FLOAT128_FUNCTIONS_HPP
10#define BOOST_MP_DETAIL_FLOAT128_FUNCTIONS_HPP
11
12#include <boost/multiprecision/detail/standalone_config.hpp>
13
14#ifndef BOOST_MP_STANDALONE
15#include <boost/cstdfloat.hpp>
16#if defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT)
17# define BOOST_MP_HAVE_CSTDFLOAT
18#endif
19#endif
20
21#if defined(BOOST_HAS_FLOAT128)
22
23namespace boost
24{
25namespace multiprecision
26{
27namespace float128_procs
28{
29extern "C" __float128 ldexpq(__float128, int) throw();
30extern "C" __float128 frexpq(__float128, int*) throw();
31extern "C" __float128 floorq(__float128) throw();
32extern "C" __float128 nextafterq(__float128, __float128) throw();
33extern "C" int isinfq(__float128) throw();
34extern "C" int isnanq(__float128) throw();
35extern "C" __float128 strtoflt128(const char*, char**) throw();
36
37#ifdef BOOST_MP_HAVE_CSTDFLOAT
38using std::ldexp;
39using std::frexp;
40using std::floor;
41using std::nextafter;
42#else
43inline __float128 ldexp(__float128 f, int i) throw() { return ldexpq(f, i); }
44inline __float128 frexp(__float128 f, int* p) throw() { return frexpq(f, p); }
45inline __float128 floor(__float128 f) throw() { return floorq(f); }
46inline __float128 nextafter(__float128 a, __float128 b) throw() { return nextafterq(a, b); }
47#endif
48}
49
50namespace detail {
51
52template <class T>
53struct is_float128 : public std::is_same<__float128, T>
54{};
55
56}
57}
58}
59
60namespace boost {
61namespace math {
62
63 inline __float128 float_next(const __float128& f)
64 {
65 return boost::multiprecision::float128_procs::nextafterq(f, 2 * f);
66 }
67 inline int (isinf)(const __float128& f)
68 {
69 return boost::multiprecision::float128_procs::isinfq(f);
70 }
71 inline int (isnan)(const __float128& f)
72 {
73 return boost::multiprecision::float128_procs::isnanq(f);
74 }
75
76}}
77
78#define BOOST_MP_FLOAT128_USING using boost::multiprecision::float128_procs::ldexp; using boost::multiprecision::float128_procs::frexp; using boost::multiprecision::float128_procs::floor; using boost::multiprecision::float128_procs::nextafter; using boost::math::isinf; using boost::math::isnan;
79
80#else
81#define BOOST_MP_FLOAT128_USING
82
83namespace boost {
84namespace multiprecision {
85namespace detail {
86
87template <class T>
88struct is_float128 : public std::false_type
89{};
90
91}}} // namespace boost::multiprecision::detail
92
93#endif
94
95#endif // BOOST_MP_DETAIL_FLOAT128_FUNCTIONS_HPP
96

source code of boost/libs/multiprecision/include/boost/multiprecision/detail/float128_functions.hpp