| 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 <eve/eve.hpp> | ||
| 11 | #include <polyfloat/details/callable.hpp> | ||
| 12 | #include <polyfloat/types/concepts.hpp> | ||
| 13 | #include <polyfloat/types/traits.hpp> | ||
| 14 | |||
| 15 | namespace plf | ||
| 16 | { | ||
| 17 | template<typename Options> struct nbmantissabits_t : eve::constant_callable<nbmantissabits_t, Options> | ||
| 18 | { | ||
| 19 | 30294 | template<typename T> POLYFLOAT_ABI static constexpr auto value(eve::as<T> const&, auto const&) | |
| 20 | { | ||
| 21 | using u_t = eve::underlying_type_t<T>; | ||
| 22 |
1/1✓ Branch 2 taken 15288 times.
|
30294 | return eve::nbmantissabits(eve::as<u_t>()) * dimension_v<T>; |
| 23 | } | ||
| 24 | |||
| 25 | template<concepts::polyfloat_like T> | ||
| 26 | 30294 | POLYFLOAT_ABI constexpr eve::as_integer_t<eve::underlying_type_t<T>> operator()(as<T> const& v) const | |
| 27 | { | ||
| 28 | 30294 | return POLYFLOAT_CALL(v); | |
| 29 | } | ||
| 30 | |||
| 31 | POLYFLOAT_CALLABLE_OBJECT(nbmantissabits_t, nbmantissabits_); | ||
| 32 | }; | ||
| 33 | //====================================================================================================================== | ||
| 34 | //! @addtogroup constants | ||
| 35 | //! @{ | ||
| 36 | //! @var nbmantissabits | ||
| 37 | //! @brief return the number of available mantissa bits. | ||
| 38 | //! | ||
| 39 | //! @groupheader{Header file} | ||
| 40 | //! | ||
| 41 | //! @code | ||
| 42 | //! #include <polyfloat/core.hpp> | ||
| 43 | //! @endcode | ||
| 44 | //! | ||
| 45 | //! @groupheader{Callable Signatures} | ||
| 46 | //! | ||
| 47 | //! @code | ||
| 48 | //! namespace polyfloat | ||
| 49 | //! { | ||
| 50 | //! template<polyfloat::concepts::polyfloat_like T> constexpr auto nbmantissabits(T z) noexcept; | ||
| 51 | //! } | ||
| 52 | //! @endcode | ||
| 53 | //! | ||
| 54 | //! **Parameters** | ||
| 55 | //! | ||
| 56 | //! * `z`: Value to process. | ||
| 57 | //! | ||
| 58 | //! **Return value** | ||
| 59 | //! | ||
| 60 | //! Returns the number of available mantissa bits. | ||
| 61 | //! | ||
| 62 | //! @groupheader{Example} | ||
| 63 | //! | ||
| 64 | //! @godbolt_todo{doc/core/constants/nbmantissabits.cpp} | ||
| 65 | //====================================================================================================================== | ||
| 66 | |||
| 67 | inline constexpr auto nbmantissabits = eve::functor<nbmantissabits_t>; | ||
| 68 | //====================================================================================================================== | ||
| 69 | //! @} | ||
| 70 | //====================================================================================================================== | ||
| 71 | } | ||
| 72 |