GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/is_bit_equal.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 19 19 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
15 namespace plf
16 {
17
18 template<typename Options>
19 struct is_bit_equal_t
20 : plf::callable<is_bit_equal_t, eve::is_bit_equal_t, Options, raw_option, pedantic_option, numeric_option>
21 {
22 // template <typename T, typename U > using b_t = bit_value_t<T, U>;
23 // template <typename T, typename U > using ui_t = as_integer_t<b_t<T, U>, unsigned>;
24
25 template<concepts::polyfloat_like Z>
26 34 POLYFLOAT_ABI constexpr auto operator()(Z z1, Z z2) const noexcept -> decltype(eve::is_bit_equal(hi(z1), hi(z2)))
27 {
28 34 return POLYFLOAT_CALL(z1, z2);
29 }
30
31 32 POLYFLOAT_CALLABLE_OBJECT(is_bit_equal_t, is_bit_equal_);
32 };
33 //======================================================================================================================
34 //! @addtogroup core
35 //! @{
36 //! @var is_bit_equal
37 //! @brief returns a logical true if and only if the element bits are all equal.
38 //!
39 //! @groupheader{Header file}
40 //!
41 //! @code
42 //! #include <polyfloat/core.hpp>
43 //! @endcode
44 //!
45 //! @groupheader{Callable Signatures}
46 //!
47 //! @code
48 //! namespace polyfloat
49 //! {
50 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto is_bit_equal(T z1, T z2) noexcept
51 //! }
52 //! @endcode
53 //!
54 //! **Parameters**
55 //!
56 //! * `z1`, `z2` : Values to process.
57 //!
58 //! **Return value**
59 //!
60 //! Returns true the element bits of `z1` and `z2`are all equal.
61 //!
62 //! @groupheader{Example}
63 //!
64 //! @godbolt{doc/core/is_bit_equal.cpp}
65 //======================================================================================================================
66
67 inline constexpr auto is_bit_equal = eve::functor<is_bit_equal_t>;
68 //======================================================================================================================
69 //! @}
70 //======================================================================================================================
71 }
72
73 namespace plf::_
74 {
75 template<typename Z, eve::callable_options O>
76 32 constexpr auto is_bit_equal_(POLYFLOAT_DELAY(), O const&, Z const& z1, Z const& z2) noexcept
77 {
78 20 if constexpr (dimension_v<Z> == 2) return eve::is_bit_equal(lo(z1), lo(z2)) && eve::is_bit_equal(hi(z1), hi(z2));
79 else if constexpr (dimension_v<Z> == 3)
80 24 return eve::is_bit_equal(lo(z1), lo(z2)) && eve::is_bit_equal(md(z1), md(z2)) &&
81 24 eve::is_bit_equal(hi(z1), hi(z2));
82 }
83 }
84