GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/signnz.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 48 48 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/minus.hpp>
15 #include <polyfloat/module/core/is_negative.hpp>
16
17 namespace plf
18 {
19
20 template<typename Options> struct signnz_t : eve::elementwise_callable<signnz_t, Options, raw_option, pedantic_option>
21 {
22 21194 template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept
23 {
24 21194 return POLYFLOAT_CALL(z);
25 }
26
27 21194 POLYFLOAT_CALLABLE_OBJECT(signnz_t, signnz_);
28 };
29 //======================================================================================================================
30 //! @addtogroup core
31 //! @{
32 //! @var signnz
33 //! @brief return the never zero sign value.
34 //!
35 //! @groupheader{Header file}
36 //!
37 //! @code
38 //! #include <polyfloat/core.hpp>
39 //! @endcode
40 //!
41 //! @groupheader{Callable Signatures}
42 //!
43 //! @code
44 //! namespace polyfloat
45 //! {
46 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto signnz(T z) noexcept;
47 //! }
48 //! @endcode
49 //!
50 //! **Parameters**
51 //!
52 //! * `z`: Value to process.
53 //!
54 //! **Return value**
55 //!
56 //! Returns the never zero sign value of z.
57 //!
58 //! @groupheader{Example}
59 //!
60 //! @godbolt_todo{doc/core/signnz.cpp}
61 //======================================================================================================================
62
63 inline constexpr auto signnz = eve::functor<signnz_t>;
64 //======================================================================================================================
65 //! @}
66 //======================================================================================================================
67 }
68
69 namespace plf::_
70 {
71 template<typename Z, eve::callable_options O>
72 21194 constexpr auto signnz_(POLYFLOAT_DELAY(), O const& o, Z const& z) noexcept
73 {
74 21194 return Z(eve::signnz[o](hi(z)));
75 // if constexpr(O::contains(eve::pedantic))
76 // return if_else(eve::is_negative(plf::hi(z)), Z(-1), Z(1));
77 }
78 }
79