| 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/ceil.hpp> | ||
| 15 | |||
| 16 | namespace plf | ||
| 17 | { | ||
| 18 | |||
| 19 | template<typename Options> struct floor_t : eve::elementwise_callable<floor_t, Options, raw_option, pedantic_option> | ||
| 20 | { | ||
| 21 | 97034 | template<concepts::polyfloat_like Z> POLYFLOAT_ABI constexpr Z operator()(Z z) const noexcept | |
| 22 | { | ||
| 23 | 97034 | return POLYFLOAT_CALL(z); | |
| 24 | } | ||
| 25 | |||
| 26 | 97034 | POLYFLOAT_CALLABLE_OBJECT(floor_t, floor_); | |
| 27 | }; | ||
| 28 | //====================================================================================================================== | ||
| 29 | //! @addtogroup core | ||
| 30 | //! @{ | ||
| 31 | //! @var floor | ||
| 32 | //! @brief return the floor 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 floor(T z) noexcept; | ||
| 46 | //! } | ||
| 47 | //! @endcode | ||
| 48 | //! | ||
| 49 | //! **Parameters** | ||
| 50 | //! | ||
| 51 | //! * `z`: Value to process. | ||
| 52 | //! | ||
| 53 | //! **Return value** | ||
| 54 | //! | ||
| 55 | //! Returns the floor value of z. | ||
| 56 | //! | ||
| 57 | //! @groupheader{Example} | ||
| 58 | //! | ||
| 59 | //! @godbolt{doc/core/floor.cpp} | ||
| 60 | //====================================================================================================================== | ||
| 61 | |||
| 62 | inline constexpr auto floor = eve::functor<floor_t>; | ||
| 63 | //====================================================================================================================== | ||
| 64 | //! @} | ||
| 65 | //====================================================================================================================== | ||
| 66 | } | ||
| 67 | |||
| 68 | namespace plf::_ | ||
| 69 | { | ||
| 70 | 97034 | template<typename Z, eve::callable_options O> constexpr auto floor_(POLYFLOAT_DELAY(), O const&, Z const& z) noexcept | |
| 71 | { | ||
| 72 | 97034 | return -ceil(-z); | |
| 73 | } | ||
| 74 | } | ||
| 75 |