34 template <
typename IntT, detail::enable_if_
integer_t<IntT> = 0>
39 template <
typename OtherFP>
40 constexpr s24x8(
const OtherFP& other,
77 static_cast<u32
>(
mValue) +
static_cast<u32
>(b.mValue)));
82 static_cast<u32
>(
mValue) -
static_cast<u32
>(b.mValue)));
115 return from_raw(a.mValue % b.mValue);
132 return from_raw(
x.mValue < 0 ? -
x.mValue :
x.mValue);
136 return x.mValue > 0 ? 1 : (
x.mValue < 0 ? -1 : 0);
140 return a + (b - a) *
t;
144 return x < lo ? lo : (
x > hi ? hi :
x);
152 constexpr s24x8 zero(0.0f);
153 constexpr s24x8 one(1.0f);
154 constexpr s24x8 two(2.0f);
155 constexpr s24x8 three(3.0f);
156 s24x8 t =
clamp((
x - edge0) / (edge1 - edge0), zero, one);
157 return t *
t * (three - two *
t);
163 constexpr s24x8 one(1.0f);
164 constexpr s24x8 pi_over_2(1.5707963f);
165 bool neg =
x.mValue < 0;
177 constexpr s24x8 pi(3.1415926f);
178 constexpr s24x8 pi_over_2(1.5707963f);
179 if (
x.mValue == 0 &&
y.mValue == 0)
return s24x8();
180 if (
x.mValue == 0)
return y.mValue > 0 ? pi_over_2 : -pi_over_2;
181 if (
y.mValue == 0)
return x.mValue > 0 ?
s24x8() : pi;
190 if (
x.mValue < 0) a = pi - a;
191 if (
y.mValue < 0) a = -a;
196 constexpr s24x8 one(1.0f);
201 constexpr s24x8 one(1.0f);
217 if (base.mValue <= 0)
return s24x8();
218 constexpr s24x8 one(1.0f);
219 if (
exp.mValue == 0)
return one;
220 if (base == one)
return one;
223 constexpr i32 kOneRaw =
static_cast<i32
>(
SCALE);
224 if (base.mValue >= (kOneRaw - 2) && base.mValue <= kOneRaw) {
311 : (v & 0x00000002u) ? r + 1
320 u32 val =
static_cast<u32
>(
x.mValue);
325 t =
static_cast<i32
>(
328 t =
static_cast<i32
>(
333 constexpr int IFRAC = 16;
334 constexpr i64 c0 = 94528LL;
335 constexpr i64 c1 = -45814LL;
336 constexpr i64 c2 = 23821LL;
337 constexpr i64 c3 = -6986LL;
342 acc = c2 + ((acc * t16) >> IFRAC);
343 acc = c1 + ((acc * t16) >> IFRAC);
344 acc = c0 + ((acc * t16) >> IFRAC);
345 i64 frac_part = (acc * t16) >> IFRAC;
347 i32 frac8 =
static_cast<i32
>(frac_part >> (IFRAC -
FRAC_BITS));
348 return from_raw(
static_cast<i32
>(
static_cast<u32
>(int_part) <<
FRAC_BITS) + frac8);
362 int_pow =
static_cast<i32
>(
SCALE) << n;
364 int_pow =
static_cast<i32
>(
SCALE) >> (-n);
368 constexpr int IFRAC = 16;
369 constexpr i64 d0 = 45427LL;
370 constexpr i64 d1 = 15775LL;
371 constexpr i64 d2 = 3497LL;
372 constexpr i64 d3 = 836LL;
377 acc = d2 + ((acc * fr16) >> IFRAC);
378 acc = d1 + ((acc * fr16) >> IFRAC);
379 acc = d0 + ((acc * fr16) >> IFRAC);
380 constexpr i64 one16 = 1LL << IFRAC;
381 i64 frac_pow16 = one16 + ((acc * fr16) >> IFRAC);
383 i32 frac_pow8 =
static_cast<i32
>(frac_pow16 >> (IFRAC -
FRAC_BITS));
393 return static_cast<u32
>(
401 constexpr s24x8 c0(0.9998779297f);
402 constexpr s24x8 c1(-0.3269348145f);
403 constexpr s24x8 c2(0.1594085693f);
404 constexpr s24x8 c3(-0.0472106934f);
406 return t * (c0 + t2 * (c1 + t2 * (c2 + t2 * c3)));
static constexpr FASTLED_FORCE_INLINE s24x8 ceil(s24x8 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 atan2(s24x8 y, s24x8 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 lerp(s24x8 a, s24x8 b, s24x8 t) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 exp2_fp(s24x8 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE int highest_bit(u32 v) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 acos(s24x8 x) FL_NOEXCEPT
FASTLED_FORCE_INLINE s24x8 sin() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 operator+(s24x8 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 sqrt(s24x8 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE int sign(s24x8 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE void sincos(s24x8 angle, s24x8 &out_sin, s24x8 &out_cos) FL_NOEXCEPT
static constexpr i32 RAD_TO_24
constexpr float to_float() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 operator*(i32 scalar) const FL_NOEXCEPT
constexpr bool operator==(s24x8 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 operator-() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 floor(s24x8 x) FL_NOEXCEPT
constexpr s24x8() FL_NOEXCEPT=default
static FASTLED_FORCE_INLINE s24x8 smoothstep(s24x8 edge0, s24x8 edge1, s24x8 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 cos(s24x8 angle) FL_NOEXCEPT
FASTLED_FORCE_INLINE s24x8 atan() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 rsqrt() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u32 angle_to_a24(s24x8 angle) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 step(s24x8 edge, s24x8 x) FL_NOEXCEPT
friend constexpr s24x8 operator*(i32 scalar, s24x8 fp) FL_NOEXCEPT
constexpr s24x8(const OtherFP &other, typename fl::enable_if<(OtherFP::INT_BITS<=INT_BITS) &&(OtherFP::FRAC_BITS<=FRAC_BITS) &&(OtherFP::INT_BITS !=INT_BITS||OtherFP::FRAC_BITS !=FRAC_BITS), int >::type=0) FL_NOEXCEPT
constexpr bool operator<(s24x8 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 from_raw(i32 raw) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE int sign() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 operator*(s24x8 b) const FL_NOEXCEPT
constexpr s24x8(IntT n) FL_NOEXCEPT
static constexpr int _highest_bit_step(u32 v, int r) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 sin(s24x8 angle) FL_NOEXCEPT
constexpr bool operator>=(s24x8 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 atan_unit(s24x8 t) FL_NOEXCEPT
constexpr i32 to_int() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s24x8 cos() const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 log2_fp(s24x8 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 mod(s24x8 a, s24x8 b) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 asin(s24x8 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 fract(s24x8 x) FL_NOEXCEPT
static constexpr i32 SCALE
constexpr FASTLED_FORCE_INLINE s24x8 operator-(s24x8 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 atan(s24x8 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 abs(s24x8 x) FL_NOEXCEPT
static constexpr int INT_BITS
constexpr FASTLED_FORCE_INLINE s24x8 operator>>(int shift) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s24x8 pow(s24x8 base, s24x8 exp) FL_NOEXCEPT
constexpr i32 raw() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 sqrt() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s24x8 acos() const FL_NOEXCEPT
static constexpr int FRAC_BITS
constexpr FASTLED_FORCE_INLINE s24x8 fract() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 rsqrt(s24x8 x) FL_NOEXCEPT
constexpr bool operator>(s24x8 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 ceil() const FL_NOEXCEPT
constexpr s24x8(i32 raw, RawTag) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s24x8 clamp(s24x8 x, s24x8 lo, s24x8 hi) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 floor() const FL_NOEXCEPT
constexpr bool operator!=(s24x8 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 operator/(s24x8 b) const FL_NOEXCEPT
constexpr bool operator<=(s24x8 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s24x8 abs() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s24x8 asin() const FL_NOEXCEPT
#define constexpr
Declares that it is possible to evaluate a value at compile time, introduced in C++11.
FASTLED_FORCE_INLINE i32 cos32(u32 angle) FL_NOEXCEPT
FASTLED_FORCE_INLINE i32 sin32(u32 angle) FL_NOEXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NOEXCEPT
FL_OPTIMIZE_FUNCTION constexpr u32 isqrt64(u64 x) FL_NOEXCEPT
Base definition for an LED controller.
#define FL_OPTIMIZATION_LEVEL_O3_BEGIN
#define FASTLED_FORCE_INLINE
#define FL_OPTIMIZATION_LEVEL_O3_END