GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/math/constants/rad2deg.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 8 8 100.0%
Functions: 12 12 100.0%
Branches: 1 1 100.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
14 namespace plf
15 {
16 template<typename Options> struct rad2deg_t : eve::constant_callable<rad2deg_t, Options>
17 {
18 40 template<typename T> POLYFLOAT_ABI static constexpr auto value(eve::as<T> const&, auto const&)
19 {
20 using u_t = eve::underlying_type_t<T>;
21
22 if constexpr (plf::dimension_v<T> == 1)
23 {
24
1/1
✓ Branch 2 taken 4 times.
8 return 180 / eve::pi(eve::as(u_t()));
25 }
26 if constexpr (plf::dimension_v<T> == 2)
27 {
28 if constexpr (std::same_as<u_t, float>)
29 8 return plf::_::from_pair<u_t>(0x1.ca5dc20000000p+5, -0x1.670f820000000p-21);
30 else if constexpr (std::same_as<u_t, double>)
31 8 return plf::_::from_pair<u_t>(0x1.ca5dc1a63c1f8p+5, -0x1.1e7ab456405f9p-49);
32 }
33 else if constexpr (plf::dimension_v<T> == 3)
34 {
35 if constexpr (std::same_as<u_t, float>)
36 8 return plf::_::from_triple<u_t>(0x1.ca5dc20000000p+5, -0x1.670f820000000p-21, -0x1.1e7ab40000000p-49);
37 else if constexpr (std::same_as<u_t, double>)
38 8 return plf::_::from_triple<u_t>(0x1.ca5dc1a63c1f8p+5, -0x1.1e7ab456405f9p-49, -0x1.b505196fabb41p-103);
39 }
40 }
41
42 40 template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const
43 {
44 40 return POLYFLOAT_CALL(v);
45 }
46
47 POLYFLOAT_CALLABLE_OBJECT(rad2deg_t, rad2deg_);
48 };
49 //======================================================================================================================
50 //! @addtogroup constants
51 //! @{
52 //! @var rad2deg
53 //! @brief return the rad2deg value.
54 //!
55 //! @groupheader{Header file}
56 //!
57 //! @code
58 //! #include <polyfloat/core.hpp>
59 //! @endcode
60 //!
61 //! @groupheader{Callable Signatures}
62 //!
63 //! @code
64 //! namespace polyfloat
65 //! {
66 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto rad2deg(T z) noexcept;
67 //! }
68 //! @endcode
69 //!
70 //! **Parameters**
71 //!
72 //! * `z`: Value to process.
73 //!
74 //! **Return value**
75 //!
76 //! Returns the rad2deg value as T.
77 //!
78 //! @groupheader{Example}
79 //!
80 //! @godbolt_todo{doc/rad2deg.cpp}
81 //======================================================================================================================
82
83 inline constexpr auto rad2deg = eve::functor<rad2deg_t>;
84 //======================================================================================================================
85 //! @}
86 //======================================================================================================================
87 }
88