GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/is_even.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 6 6 100.0%
Functions: 41 41 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 <type_traits>
14 #include <polyfloat/module/core/is_flint.hpp>
15 #include <polyfloat/module/core/ldexp.hpp>
16
17 namespace plf
18 {
19
20 template<typename Options>
21 struct is_even_t : plf::elementwise_callable<is_even_t, eve::is_even_t, Options, raw_option, pedantic_option>
22 {
23 template<concepts::polyfloat_like Z>
24 97143 POLYFLOAT_ABI constexpr eve::as_logical_t<plf::as_component_type_t<Z>> operator()(Z z) const noexcept
25 {
26 97143 return POLYFLOAT_CALL(z);
27 }
28
29 95521 POLYFLOAT_CALLABLE_OBJECT(is_even_t, is_even_);
30 };
31
32 //================================================================================================
33 //! @addtogroup core
34 //! @{
35 //! @var is_even
36 //! @brief returns a logical true if and only if the element value is a floating value
37 //! representing an even integer
38 //!
39 //! @groupheader{Header file}
40 //!
41 //! @code
42 //! #include <eve/module/module/core.hpp>
43 //! @endcode
44 //!
45 //! @groupheader{Callable Signatures}
46 //!
47 //! @code
48 //! namespace plf
49 //! {
50 //! // Regular overloads
51 //! constexpr auto is_even(floating_value auto x) noexcept;
52 //! }
53 //! @endcode
54 //!
55 //! **Parameters**
56 //!
57 //! * `x`: [argument](@ref eve::value).
58 //!
59 //! **Return value**
60 //!
61 //! 1. returns true if and only if x represent an even number
62 //!
63 //! @groupheader{Example}
64 //! @godbolt{doc/core/is_even.cpp}
65 //================================================================================================
66 inline constexpr auto is_even = eve::functor<is_even_t>;
67 //======================================================================================================================
68 //! @}
69 //======================================================================================================================
70 }
71
72 namespace plf::_
73 {
74 template<typename Z, eve::callable_options O>
75 95521 constexpr auto is_even_(POLYFLOAT_DELAY(), O const&, Z const& z) noexcept
76 {
77 95521 auto t = is_flint(z);
78 95521 return t && is_flint(ldexp(z, -1));
79 }
80 }
81