GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/constants/sqrt_2.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 10 10 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //======================================================================================================================
2 /*
3 POLYFLOAT - Extended precision floating points
4 Copyright : POLYFLOAT Contributors & Maintainers
5 SPDX-License-Identifier: BSL-1.0
6 */
7 //======================================================================================================================
8 #pragma once
9
10 #include <polyfloat/details/callable.hpp>
11 #include <polyfloat/types/concepts.hpp>
12 #include <polyfloat/types/traits.hpp>
13 #include <eve/module/math/constant/sqrt_2.hpp>
14
15 namespace plf
16 {
17 template<typename Options>
18 struct sqrt_2_t : plf::constant_callable<sqrt_2_t, eve::sqrt_2_t, Options, lower_option, upper_option>
19 {
20 20 template<typename T> POLYFLOAT_ABI static constexpr auto value(eve::as<T> const&, auto const&)
21 {
22 using u_t = eve::underlying_type_t<T>;
23
24 if constexpr (plf::dimension_v<T> == 2)
25 {
26 6 if constexpr (sizeof(u_t) == 8) return plf::_::from_pair<u_t>(0x1.6a09e667f3bcdp+0, -0x1.bdd3413b26456p-54);
27 4 else return plf::_::from_pair<u_t>(0x1.6a09e6p+0, 0x1.9fcef4p-26);
28 }
29 else if constexpr (plf::dimension_v<T> == 3)
30 {
31 if constexpr (sizeof(u_t) == 8)
32 6 return plf::_::from_triple<u_t>(0x1.6a09e667f3bcdp+0, -0x1.bdd3413b26456p-54, 0x1.57d3e3adec175p-108);
33 4 else return plf::_::from_triple<u_t>(0x1.6a09e6p+0, 0x1.9fcef4p-26, -0x1.b7ba68p-51);
34 }
35 }
36
37 28 template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const
38 {
39 28 return POLYFLOAT_CALL(v);
40 }
41
42 POLYFLOAT_CALLABLE_OBJECT(sqrt_2_t, sqrt_2_);
43 };
44 //======================================================================================================================
45 //! @addtogroup constants
46 //! @{
47 //! @var sqrt_2
48 //! @brief return the sqrt of 2.
49 //!
50 //! @groupheader{Header file}
51 //!
52 //! @code
53 //! #include <polyfloat/core.hpp>
54 //! @endcode
55 //!
56 //! @groupheader{Callable Signatures}
57 //!
58 //! @code
59 //! namespace polyfloat
60 //! {
61 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto sqrt_2(T z) noexcept;
62 //! }
63 //! @endcode
64 //!
65 //! **Parameters**
66 //!
67 //! * `z`: Value to process.
68 //!
69 //! **Return value**
70 //!
71 //! Returns the sqrt of 2.
72 //!
73 //! @groupheader{Example}
74 //!
75 //! @godbolt{doc/core/sqrt_2.cpp}
76 //======================================================================================================================
77
78 inline constexpr auto sqrt_2 = eve::functor<sqrt_2_t>;
79 //======================================================================================================================
80 //! @}
81 //======================================================================================================================
82 }
83