| 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> | ||
| 18 | struct effective_mantissa_bits_t : eve::constant_callable<effective_mantissa_bits_t, Options> | ||
| 19 | { | ||
| 20 | 60 | template<typename T> POLYFLOAT_ABI static constexpr eve::as_integer_t<T> value(eve::as<T> const&, auto const&) | |
| 21 | { | ||
| 22 | using u_t = eve::underlying_type_t<T>; | ||
| 23 |
1/1✓ Branch 2 taken 40 times.
|
60 | return (eve::nbmantissabits(eve::as<u_t>()) + 1) * dimension_v<T>; |
| 24 | } | ||
| 25 | |||
| 26 | 60 | template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const | |
| 27 | { | ||
| 28 | 60 | return POLYFLOAT_CALL(v); | |
| 29 | } | ||
| 30 | |||
| 31 | POLYFLOAT_CALLABLE_OBJECT(effective_mantissa_bits_t, effective_mantissa_bits_); | ||
| 32 | }; | ||
| 33 | //====================================================================================================================== | ||
| 34 | //! @addtogroup constants | ||
| 35 | //! @{ | ||
| 36 | //! @var effective_mantissa_bits | ||
| 37 | //! @brief return the maximal representable flint value. | ||
| 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 effective_mantissa_bits(T z) noexcept; | ||
| 51 | //! } | ||
| 52 | //! @endcode | ||
| 53 | //! | ||
| 54 | //! **Parameters** | ||
| 55 | //! | ||
| 56 | //! * `z` : [Type wrapper](@ref eve::as) instance embedding the type of the constant. | ||
| 57 | //! | ||
| 58 | //! **Return value** | ||
| 59 | //! | ||
| 60 | //! Returns the effective number of bits of the mantissa value. | ||
| 61 | //! | ||
| 62 | //! @groupheader{Example} | ||
| 63 | //! | ||
| 64 | //! @godbolt_todo{doc/effective_mantissa_bits.cpp} | ||
| 65 | //====================================================================================================================== | ||
| 66 | |||
| 67 | inline constexpr auto effective_mantissa_bits = eve::functor<effective_mantissa_bits_t>; | ||
| 68 | //====================================================================================================================== | ||
| 69 | //! @} | ||
| 70 | //====================================================================================================================== | ||
| 71 | } | ||
| 72 |