8#ifndef LIBFXD_LIMITS_HPP
9#define LIBFXD_LIMITS_HPP
17#include "detail/types.hpp"
20#define LIBFXD_LOG10_2(x) ((x) * 643L / 2136)
21#define LIBFXD_LOG10_2_CEIL(x) (((x) * 643L + 2135) / 2136)
29 requires (numeric_limits<Raw>::is_specialized)
32 static_assert(numeric_limits<Raw>::radix == 2);
33 static_assert(Frac < 2136);
36 static constexpr bool is_specialized =
true;
39 static constexpr bool is_signed = numeric_limits<Raw>::is_signed;
42 static constexpr bool is_integer = Frac <= 0;
45 static constexpr bool is_exact =
true;
48 static constexpr bool has_infinity =
false;
51 static constexpr bool has_quiet_NaN =
false;
54 static constexpr bool has_signaling_NaN =
false;
57 static constexpr float_denorm_style has_denorm = denorm_absent;
60 static constexpr bool has_denorm_loss =
false;
63 static constexpr float_round_style round_style = round_toward_zero;
66 static constexpr bool is_iec559 =
false;
69 static constexpr bool is_bounded = numeric_limits<Raw>::is_bounded;
72 static constexpr bool is_modulo = numeric_limits<Raw>::is_modulo;
75 static constexpr int radix = numeric_limits<Raw>::radix;
87 static constexpr int min_exponent = 1 - Frac;
93 static constexpr int max_exponent = Int - is_signed;
99 static constexpr bool traps = numeric_limits<Raw>::traps;
102 static constexpr bool tinyness_before =
false;
105 static constexpr int max_bit = Int - is_signed;
108 static constexpr int min_bit = - Frac;
131 if constexpr (is_signed)
132 return Fxd::from_raw(Raw{-1} << (Fxd::bits - 1));
134 return Fxd::from_raw(0);
145 if constexpr (is_signed) {
146 using URaw = make_unsigned_t<Raw>;
147 return Fxd::from_raw((URaw{1} << (Int + Frac - 1)) - URaw{1});
149 return Fxd::from_raw(~Raw{0});
229#undef LIBFXD_LOG10_2_CEIL
#define LIBFXD_LOG10_2(x)
#define LIBFXD_LOG10_2_CEIL(x)
The fixed-point class template.
static constexpr fixed from_raw(raw_type val) noexcept
Constructs a fixed from any raw bit representation (no conversion.)
static constexpr fxd::fixed< Int, Frac, Raw > infinity() noexcept
Not meaningful, has_infinity is false.
static constexpr fxd::fixed< Int, Frac, Raw > epsilon() noexcept
Smallest increment.
static constexpr fxd::fixed< Int, Frac, Raw > min() noexcept
Smallest positive value; same semantics as floating-point.
static constexpr fxd::fixed< Int, Frac, Raw > lowest() noexcept
Closest value to -∞.
fxd::detail::select_float_t< digits > float_type
Extension: lossless conversion to a floating-point type.
static constexpr fxd::fixed< Int, Frac, Raw > max() noexcept
Maximum value.
static constexpr fxd::fixed< Int, Frac, Raw > round_error() noexcept
Maximum possible error.
static constexpr fxd::fixed< Int, Frac, Raw > max_pow2() noexcept
Extension: maximum power of two.
static constexpr fxd::fixed< Int, Frac, Raw > quiet_NaN() noexcept
Not meaningful, has_quiet_NaN is false.
static constexpr fxd::fixed< Int, Frac, Raw > signaling_NaN() noexcept
Not meaningful, has_signaling_NaN is false.
static constexpr fxd::fixed< Int, Frac, Raw > denorm_min() noexcept
Same as min() since there are no denormalized values.