GCC Code Coverage Report


Directory: include/polyfloat/
File: include/polyfloat/module/core/constants/valmin.hpp
Date: 2026-11-09 15:28:50
Exec Total Coverage
Lines: 8 8 100.0%
Functions: 11 11 100.0%
Branches: 3 3 100.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 <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 valmin_t : plf::constant_callable<valmin_t, eve::valmin_t, Options, lower_option, upper_option>
19 {
20 70 template<typename T> POLYFLOAT_ABI static constexpr T value(eve::as<T> const&, auto const&)
21 {
22 using u_t = eve::underlying_type_t<T>;
23
1/1
✓ Branch 2 taken 35 times.
70 auto vlm = eve::valmin(eve::as<u_t>());
24 if constexpr (dimension_v<T> == 2)
25 {
26
1/1
✓ Branch 2 taken 18 times.
36 auto nbts = -plf::effective_mantissa_bits(eve::as<u_t>());
27 36 return plf::_::from_pair(vlm, eve::ldexp(vlm, nbts));
28 }
29 else if constexpr (dimension_v<T> == 3)
30 {
31
1/1
✓ Branch 2 taken 17 times.
34 auto nbts = -plf::effective_mantissa_bits(eve::as<u_t>());
32 34 return plf::_::from_triple(vlm, eve::ldexp(vlm, nbts), eve::ldexp(vlm, 2 * nbts - 1));
33 }
34 }
35
36 74 template<concepts::polyfloat_like T> POLYFLOAT_ABI constexpr T operator()(as<T> const& v) const
37 {
38 74 return POLYFLOAT_CALL(v);
39 }
40
41 POLYFLOAT_CALLABLE_OBJECT(valmin_t, valmin_);
42 };
43 //======================================================================================================================
44 //! @addtogroup constants
45 //! @{
46 //! @var valmin
47 //! @brief return the minimal representable flint value.
48 //!
49 //! @groupheader{Header file}
50 //!
51 //! @code
52 //! #include <polyfloat/core.hpp>
53 //! @endcode
54 //!
55 //! @groupheader{Callable Signatures}
56 //!
57 //! @code
58 //! namespace polyfloat
59 //! {
60 //! template<polyfloat::concepts::polyfloat_like T> constexpr auto valmin(T z) noexcept;
61 //! }
62 //! @endcode
63 //!
64 //! **Parameters**
65 //!
66 //! * `z` : [Type wrapper](@ref eve::as) instance embedding the type of the constant.
67 //!
68 //! **Return value**
69 //!
70 //! Returns the effective number of bits of the mantissa value.
71 //!
72 //! @groupheader{Example}
73 //!
74 //! @godbolt_todo{doc/valmin.cpp}
75 //======================================================================================================================
76
77 inline constexpr auto valmin = eve::functor<valmin_t>;
78 //======================================================================================================================
79 //! @}
80 //======================================================================================================================
81 }
82