GCC Code Coverage Report


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