GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/ceil.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 19 19 100.0%
Functions: 42 42 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/if_else.hpp>
15 #include <polyfloat/module/core/inc.hpp>
16 #include <polyfloat/module/core/is_negative.hpp>
17
18 namespace plf
19 {
20
21 template<typename Options>
22 struct ceil_t : plf::elementwise_callable<ceil_t, eve::ceil_t, Options, raw_option, pedantic_option>
23 {
24 418812 template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept
25 {
26 418812 return POLYFLOAT_CALL(z);
27 }
28
29 109123 POLYFLOAT_CALLABLE_OBJECT(ceil_t, ceil_);
30 };
31 //======================================================================================================================
32 //! @addtogroup core
33 //! @{
34 //! @var ceil
35 //! @brief return the ceil value.
36 //!
37 //! @groupheader{Header file}
38 //!
39 //! @code
40 //! #include <polyfloat/core.hpp>
41 //! @endcode
42 //!
43 //! @groupheader{Callable Signatures}
44 //!
45 //! @code
46 //! namespace polyfloat
47 //! {
48 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto ceil(T z) noexcept;
49 //! }
50 //! @endcode
51 //!
52 //! **Parameters**
53 //!
54 //! * `z`: Value to process.
55 //!
56 //! **Return value**
57 //!
58 //! Returns the ceil value of z.
59 //!
60 //! @groupheader{Example}
61 //!
62 //! @godbolt{doc/core/ceil.cpp}
63 //======================================================================================================================
64
65 inline constexpr auto ceil = eve::functor<ceil_t>;
66 //======================================================================================================================
67 //! @}
68 //======================================================================================================================
69 }
70
71 namespace plf::_
72 {
73 109123 template<typename Z, eve::callable_options O> constexpr auto ceil_(POLYFLOAT_DELAY(), O const&, Z const& z) noexcept
74 {
75 if constexpr (dimension_v<Z> == 2)
76 {
77 21648 auto [h, l] = z;
78
79 21648 auto iflh = eve::is_flint(h);
80 21648 auto ifll = eve::is_flint(l);
81 21648 auto ch = ceil(h);
82 21648 auto z1 = if_else(!iflh, Z(ch), Z(ch, ceil(l)));
83 21648 return if_else(iflh && ifll, z, z1);
84 }
85 else if constexpr (dimension_v<Z> == 3)
86 {
87 87475 auto [h, m, l] = z;
88 87475 auto iflh = eve::is_flint(h);
89 87475 auto iflm = eve::is_flint(m);
90 87475 auto ifll = eve::is_flint(l);
91 87475 auto ch = ceil(h);
92 87475 auto cm = ceil(m);
93 87475 auto cl = ceil(l);
94 87475 auto z1 = if_else(!iflh, Z(ch), if_else(!iflm, Z(ch, cm), Z(ch, cm, cl)));
95 87475 return if_else(iflh && iflm && ifll, z, z1);
96 }
97 }
98 }
99