38template <
typename IntT>
41 static_cast<u32
>(n) <= max_u;
47template <
int IntBits,
int FracBits,
bool TotalLE16 = (IntBits + FracBits <= 16)>
52template <
int IntBits,
int FracBits>
54 static constexpr i32
SCALE =
static_cast<i32
>(1) << FracBits;
55 static constexpr i32
MAX_S = (
static_cast<i32
>(1) << (IntBits - 1)) - 1;
56 static constexpr i32
MIN_S = -(
static_cast<i32
>(1) << (IntBits - 1));
57 static constexpr u32
MAX_U = (
static_cast<u32
>(1) << IntBits) - 1;
59 template <
typename IntT>
61 return (
static_cast<i32
>(n) >=
MIN_S &&
static_cast<i32
>(n) <=
MAX_S)
62 ?
static_cast<i16
>(
static_cast<i32
>(n) *
SCALE)
66 template <
typename IntT>
69 ?
static_cast<u16
>(
static_cast<u32
>(n) *
SCALE)
76template <
int IntBits,
int FracBits>
78 static constexpr u32
USCALE =
static_cast<u32
>(
static_cast<i32
>(1) << FracBits);
79 static constexpr i32
MAX_S = (
static_cast<i32
>(1) << (IntBits - 1)) - 1;
80 static constexpr i32
MIN_S = -(
static_cast<i32
>(1) << (IntBits - 1));
81 static constexpr u32
MAX_U = (
static_cast<u32
>(1) << IntBits) - 1;
83 template <
typename IntT>
85 return (
static_cast<i32
>(n) >=
MIN_S &&
static_cast<i32
>(n) <=
MAX_S)
86 ?
static_cast<i32
>(
static_cast<u32
>(n) *
USCALE)
90 template <
typename IntT>
93 ?
static_cast<u32
>(n) *
USCALE
100template <
int IntBits,
int FracBits>
121 (FracBits >= 24) ? FracBits :
122 (FracBits >= 16) ? 24 :
123 (FracBits >= 12) ? 20 :
124 (FracBits >= 8) ? 16 : 12;
131 (TOTAL_BITS <= 16) ? static_cast<raw_type>(0x7FFF)
132 : static_cast<
raw_type>(0x7FFFFFFF);
145 "intermediate_type too narrow for operator* overflow safety");
156 "poly_intermediate_type insufficient for polynomial evaluation");
void integer_out_of_range_for_fixed_point_type() FL_NOEXCEPT
typename fl::enable_if< is_non_bool_integer< T >::value, int >::type enable_if_integer_t
constexpr bool in_unsigned_range(IntT n, u32 max_u) FL_NOEXCEPT
Compile-time linker keep-alive hook for a single fl::Bus.
typename conditional< B, T, F >::type conditional_t
Base definition for an LED controller.
Portable compile-time assertion wrapper.
static constexpr u32 from_unsigned(IntT n) FL_NOEXCEPT
static constexpr i32 from_signed(IntT n) FL_NOEXCEPT
static constexpr u32 MAX_U
static constexpr i32 MAX_S
static constexpr i32 MIN_S
static constexpr u32 USCALE
static constexpr u32 MAX_U
static constexpr u16 from_unsigned(IntT n) FL_NOEXCEPT
static constexpr i32 MIN_S
static constexpr i32 SCALE
static constexpr i32 MAX_S
static constexpr i16 from_signed(IntT n) FL_NOEXCEPT
static constexpr bool value
fl::conditional_t<(TOTAL_BITS<=16), i16, i32 > raw_type
static constexpr int SIN_COS_SHIFT
fl::conditional_t<(IFRAC<=16), i32, i64 > poly_intermediate_type
static constexpr bool USE_ISQRT32
static constexpr auto MAX_OVERFLOW
FL_STATIC_ASSERT(sizeof(intermediate_type) *8 >=TOTAL_BITS *2, "intermediate_type too narrow for operator* overflow safety")
fl::conditional_t<(TOTAL_BITS<=16), u16, u32 > unsigned_raw_type
static constexpr int IFRAC
FL_STATIC_ASSERT((IFRAC<=16 &&sizeof(poly_intermediate_type) *8 >=32)||(IFRAC > 16 &&sizeof(poly_intermediate_type) *8 >=64), "poly_intermediate_type insufficient for polynomial evaluation")
fl::conditional_t<(TOTAL_BITS<=16), i32, i64 > intermediate_type
static constexpr int TOTAL_BITS
fl::conditional_t<(TOTAL_BITS<=16), u32, u64 > unsigned_intermediate_type