| 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 nextint_t : plf::elementwise_callable<nextint_t, eve::nextint_t, Options, raw_option, pedantic_option> | ||
| 20 | { | ||
| 21 | 8 | template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept | |
| 22 | { | ||
| 23 | 8 | return POLYFLOAT_CALL(z); | |
| 24 | } | ||
| 25 | |||
| 26 | 8 | POLYFLOAT_CALLABLE_OBJECT(nextint_t, nextint_); | |
| 27 | }; | ||
| 28 | //====================================================================================================================== | ||
| 29 | //! @addtogroup core | ||
| 30 | //! @{ | ||
| 31 | //! @var nextint | ||
| 32 | //! @brief returns the greatest flint less than the input. | ||
| 33 | //! | ||
| 34 | //! @groupheader{Header file} | ||
| 35 | //! | ||
| 36 | //! @code | ||
| 37 | //! #include <polyfloat/module/core.hpp> | ||
| 38 | //! @endcode | ||
| 39 | //! | ||
| 40 | //! @groupheader{Callable Signatures} | ||
| 41 | //! | ||
| 42 | //! @code | ||
| 43 | //! namespace polyfloat | ||
| 44 | //! { | ||
| 45 | //! constexpr auto nextint(value auto x) noexcept; | ||
| 46 | //! } | ||
| 47 | //! @endcode | ||
| 48 | //! | ||
| 49 | //! **Parameters** | ||
| 50 | //! | ||
| 51 | //! * `z`: Value to process. | ||
| 52 | //! | ||
| 53 | //! **Return value** | ||
| 54 | //! | ||
| 55 | //! Returns the greatest flint less than the input. | ||
| 56 | //! | ||
| 57 | //! @groupheader{Example} | ||
| 58 | //! | ||
| 59 | //! @godbolt_todo{doc/core/nextint.cpp} | ||
| 60 | //====================================================================================================================== | ||
| 61 | |||
| 62 | inline constexpr auto nextint = eve::functor<nextint_t>; | ||
| 63 | //====================================================================================================================== | ||
| 64 | //! @} | ||
| 65 | //====================================================================================================================== | ||
| 66 | } | ||
| 67 | |||
| 68 | namespace plf::_ | ||
| 69 | { | ||
| 70 | template<typename Z, eve::callable_options O> | ||
| 71 | 8 | constexpr auto nextint_(POLYFLOAT_DELAY(), O const& o, Z const& v) noexcept | |
| 72 | { | ||
| 73 | 8 | auto ni = plf::ceil(plf::next[o.drop(raw)](v)); | |
| 74 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
8 | if (!O::contains(raw)) ni = if_else(plf::is_nan(v), v, ni); |
| 75 | 8 | return ni; | |
| 76 | } | ||
| 77 | } | ||
| 78 |