GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/remainder.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 6 6 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/trunc.hpp>
15 #include <polyfloat/module/core/nearest.hpp>
16 #include <polyfloat/module/core/ceil.hpp>
17 #include <polyfloat/module/core/floor.hpp>
18
19 namespace plf
20 {
21
22 template<typename Options> struct remainder_t : eve::callable<remainder_t, Options, raw_option, pedantic_option>
23 {
24 template<concepts::polyfloat_like Z1, concepts::polyfloat_like Z2>
25 4 POLYFLOAT_ABI constexpr as_polyfloat_like_t<Z1, Z2> operator()(Z1 z1, Z2 z2) const noexcept
26 {
27 4 return POLYFLOAT_CALL(z1, z2);
28 }
29
30 4 POLYFLOAT_CALLABLE_OBJECT(remainder_t, remainder_);
31 };
32 //======================================================================================================================
33 //! @addtogroup core
34 //! @{
35 //! @var remainder
36 //! @brief return the remainder after division of the values.
37 //!
38 //! @groupheader{Header file}
39 //!
40 //! @code
41 //! #include <polyfloat/core.hpp>
42 //! @endcode
43 //!
44 //! @groupheader{Callable Signatures}
45 //!
46 //! @code
47 //! namespace polyfloat
48 //! {
49 //! template<polyfloat::concepts::polyfloat_like T1, polyfloat_like T2> constexpr auto remainder(T1 x, T2 y) noexcept; //1
50 //! }
51 //! @endcode
52 //!
53 //! **Parameters**
54 //!
55 //! * `z1`, `z2`: Values to process.
56 //!
57 //! **Return value**
58 //!
59 //! Return the remainder after division of `x` by `y` and is equivalent to `x-div[to_nearest](x, y)*y`.
60 //!
61 //!
62 //! @groupheader{Example}
63 //!
64 //! @godbolt_todo{doc/core/remainder.cpp}
65 //======================================================================================================================
66
67 inline constexpr auto remainder = eve::functor<remainder_t>;
68 //======================================================================================================================
69 //! @}
70 //======================================================================================================================
71 }
72
73 namespace plf::_
74 {
75 template<typename T0, typename T1, eve::callable_options O>
76 4 constexpr auto remainder_(POLYFLOAT_DELAY(), O const&, T0 const& a, T1 const& b) noexcept
77 {
78 4 return plf::rem[to_nearest](a, b);
79 }
80 }
81