1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: libcpp-no-concepts
11 
12 #include <cassert>
13 #include <numbers>
14 
tests()15 constexpr bool tests() {
16   assert(std::numbers::e == 0x1.5bf0a8b145769p+1);
17   assert(std::numbers::e_v<double> == 0x1.5bf0a8b145769p+1);
18   assert(std::numbers::e_v<long double> == 0x1.5bf0a8b145769p+1l);
19   assert(std::numbers::e_v<float> == 0x1.5bf0a8p+1f);
20 
21   assert(std::numbers::log2e == 0x1.71547652b82fep+0);
22   assert(std::numbers::log2e_v<double> == 0x1.71547652b82fep+0);
23   assert(std::numbers::log2e_v<long double> == 0x1.71547652b82fep+0l);
24   assert(std::numbers::log2e_v<float> == 0x1.715476p+0f);
25 
26   assert(std::numbers::log10e == 0x1.bcb7b1526e50ep-2);
27   assert(std::numbers::log10e_v<double> == 0x1.bcb7b1526e50ep-2);
28   assert(std::numbers::log10e_v<long double> == 0x1.bcb7b1526e50ep-2l);
29   assert(std::numbers::log10e_v<float> == 0x1.bcb7b15p-2f);
30 
31   assert(std::numbers::pi == 0x1.921fb54442d18p+1);
32   assert(std::numbers::pi_v<double> == 0x1.921fb54442d18p+1);
33   assert(std::numbers::pi_v<long double> == 0x1.921fb54442d18p+1l);
34   assert(std::numbers::pi_v<float> == 0x1.921fb54p+1f);
35 
36   assert(std::numbers::inv_pi == 0x1.45f306dc9c883p-2);
37   assert(std::numbers::inv_pi_v<double> == 0x1.45f306dc9c883p-2);
38   assert(std::numbers::inv_pi_v<long double> == 0x1.45f306dc9c883p-2l);
39   assert(std::numbers::inv_pi_v<float> == 0x1.45f306p-2f);
40 
41   assert(std::numbers::inv_sqrtpi == 0x1.20dd750429b6dp-1);
42   assert(std::numbers::inv_sqrtpi_v<double> == 0x1.20dd750429b6dp-1);
43   assert(std::numbers::inv_sqrtpi_v<long double> == 0x1.20dd750429b6dp-1l);
44   assert(std::numbers::inv_sqrtpi_v<float> == 0x1.20dd76p-1f);
45 
46   assert(std::numbers::ln2 == 0x1.62e42fefa39efp-1);
47   assert(std::numbers::ln2_v<double> == 0x1.62e42fefa39efp-1);
48   assert(std::numbers::ln2_v<long double> == 0x1.62e42fefa39efp-1l);
49   assert(std::numbers::ln2_v<float> == 0x1.62e42fp-1f);
50 
51   assert(std::numbers::ln10 == 0x1.26bb1bbb55516p+1);
52   assert(std::numbers::ln10_v<double> == 0x1.26bb1bbb55516p+1);
53   assert(std::numbers::ln10_v<long double> == 0x1.26bb1bbb55516p+1l);
54   assert(std::numbers::ln10_v<float> == 0x1.26bb1bp+1f);
55 
56   assert(std::numbers::sqrt2 == 0x1.6a09e667f3bcdp+0);
57   assert(std::numbers::sqrt2_v<double> == 0x1.6a09e667f3bcdp+0);
58   assert(std::numbers::sqrt2_v<long double> == 0x1.6a09e667f3bcdp+0l);
59   assert(std::numbers::sqrt2_v<float> == 0x1.6a09e6p+0f);
60 
61   assert(std::numbers::sqrt3 == 0x1.bb67ae8584caap+0);
62   assert(std::numbers::sqrt3_v<double> == 0x1.bb67ae8584caap+0);
63   assert(std::numbers::sqrt3_v<long double> == 0x1.bb67ae8584caap+0l);
64   assert(std::numbers::sqrt3_v<float> == 0x1.bb67aep+0f);
65 
66   assert(std::numbers::inv_sqrt3 == 0x1.279a74590331cp-1);
67   assert(std::numbers::inv_sqrt3_v<double> == 0x1.279a74590331cp-1);
68   assert(std::numbers::inv_sqrt3_v<long double> == 0x1.279a74590331cp-1l);
69   assert(std::numbers::inv_sqrt3_v<float> == 0x1.279a74p-1f);
70 
71   assert(std::numbers::egamma == 0x1.2788cfc6fb619p-1);
72   assert(std::numbers::egamma_v<double> == 0x1.2788cfc6fb619p-1);
73   assert(std::numbers::egamma_v<long double> == 0x1.2788cfc6fb619p-1l);
74   assert(std::numbers::egamma_v<float> == 0x1.2788cfp-1f);
75 
76   assert(std::numbers::phi == 0x1.9e3779b97f4a8p+0);
77   assert(std::numbers::phi_v<double> == 0x1.9e3779b97f4a8p+0);
78   assert(std::numbers::phi_v<long double> == 0x1.9e3779b97f4a8p+0l);
79   assert(std::numbers::phi_v<float> == 0x1.9e3779ap+0f);
80 
81   return true;
82 }
83 
84 static_assert(tests());
85 
main(int,char **)86 int main(int, char**) {
87   tests();
88   return 0;
89 }
90