]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/test/ccmath_ilogb_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / ccmath_ilogb_test.cpp
CommitLineData
1e59de90
TL
1// (C) Copyright Matt Borland 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#include <cmath>
7#include <cfloat>
8#include <cstdint>
9#include <limits>
10#include <type_traits>
11#include <boost/math/ccmath/ilogb.hpp>
12#include <boost/math/ccmath/isnan.hpp>
13#include <boost/math/ccmath/isinf.hpp>
14
15#ifdef BOOST_HAS_FLOAT128
16#include <boost/multiprecision/float128.hpp>
17#endif
18
19template <typename T>
20constexpr void test()
21{
22 if constexpr (std::numeric_limits<T>::has_quiet_NaN)
23 {
24 static_assert(boost::math::ccmath::ilogb(std::numeric_limits<T>::quiet_NaN()) == FP_ILOGBNAN, "If arg is a NaN, FP_ILOGBNAN is returned.");
25 }
26
27 static_assert(boost::math::ccmath::ilogb(T(0)) == FP_ILOGB0, "If arg is zero, FP_ILOGB0 is returned");
28 static_assert(boost::math::ccmath::ilogb(std::numeric_limits<T>::infinity()) == INT_MAX, "If arg is infinite, INT_MAX is returned");
29
30 // 123.45 = 1.92891 * 2^6
31 constexpr int test_exp = boost::math::ccmath::ilogb(T(123.45));
32 static_assert(test_exp == 6);
33}
34
35#if !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION) && !defined(BOOST_MATH_USING_BUILTIN_CONSTANT_P)
36int main()
37{
38 test<float>();
39 test<double>();
40
41 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
42 test<long double>();
43 #endif
44
45 #ifdef BOOST_HAS_FLOAT128
46 test<boost::multiprecision::float128>();
47 #endif
48
49 return 0;
50}
51#else
52int main()
53{
54 return 0;
55}
56#endif