GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/constants/eps.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 16 16 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
14 namespace plf
15 {
16 template<typename Options>
17 struct eps_t : plf::constant_callable<eps_t, eve::eps_t, Options, lower_option, upper_option>
18 {
19 1848 template<typename T> POLYFLOAT_ABI static constexpr auto value(eve::as<T> const&, auto const&)
20 {
21 using u_t = eve::underlying_type_t<T>;
22
23 if constexpr (plf::dimension_v<T> == 2)
24 {
25 if constexpr (std::same_as<u_t, eve::float16_t>) return T(0x1p-20);
26 306 else if constexpr (std::same_as<u_t, float>) return T(0x1p-48);
27 352 else if constexpr (std::same_as<u_t, double>) return T(0x1p-104);
28 }
29 else if constexpr (plf::dimension_v<T> == 3)
30 {
31 if constexpr (std::same_as<u_t, eve::float16_t>) return T(0x1p-30);
32 562 else if constexpr (std::same_as<u_t, float>) return T(0x1p-72);
33 628 else if constexpr (std::same_as<u_t, double>) return T(0x1p-156);
34 }
35 else
36 {
37 return eve::eps(eve::as<u_t>());
38 }
39 }
40
41 1860 template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const
42 {
43 1860 return POLYFLOAT_CALL(v);
44 }
45
46 POLYFLOAT_CALLABLE_OBJECT(eps_t, eps_);
47 };
48 //======================================================================================================================
49 //! @addtogroup constants
50 //! @{
51 //! @var eps
52 //! @brief return the ep value.
53 //!
54 //! @groupheader{Header file}
55 //!
56 //! @code
57 //! #include <polyfloat/core.hpp>
58 //! @endcode
59 //!
60 //! @groupheader{Callable Signatures}
61 //!
62 //! @code
63 //! namespace polyfloat
64 //! {
65 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto eps(T z) noexcept;
66 //! }
67 //! @endcode
68 //!
69 //! **Parameters**
70 //!
71 //! * `z`: Value to process.
72 //!
73 //! **Return value**
74 //!
75 //! Returns the eps value of z.
76 //!
77 //! @groupheader{Example}
78 //!
79 //! @godbolt_todo{doc/eps.cpp}
80 //======================================================================================================================
81
82 inline constexpr auto eps = eve::functor<eps_t>;
83 //======================================================================================================================
84 //! @}
85 //======================================================================================================================
86 }
87