FastLED 3.9.15
Loading...
Searching...
No Matches

◆ pow()

template<typename Derived, int IntBits, int FracBits>
static FASTLED_FORCE_INLINE Derived fl::fixed_point_base< Derived, IntBits, FracBits >::pow ( Derived base,
Derived exp )
inlinestatic

Definition at line 234 of file base.h.

234 {
235 if (base.mValue <= 0) return Derived();
236 constexpr Derived one(1.0f);
237 if (exp.mValue == 0) return one;
238 if (base == one) return one;
239 // Snap base values within ~2 ULPs of 1.0 to exactly 1.0 to dodge the
240 // log2(1+t) minimax polynomial's upper-endpoint residual (off by
241 // 0.000443 at t=1, which amplifies via exp2 to ~50-100 LSB at u16
242 // scale). See #2969.
243 constexpr raw_type kNearOneEpsilon = static_cast<raw_type>(2);
244 constexpr raw_type kOneRaw = static_cast<raw_type>(Derived::SCALE);
245 if (base.mValue >= static_cast<raw_type>(kOneRaw - kNearOneEpsilon) &&
246 base.mValue <= kOneRaw) {
247 return one;
248 }
249 return exp2_fp(exp * log2_fp(base));
250 }
typename traits::raw_type raw_type
Definition base.h:31
raw_type mValue
Definition base.h:41
static FASTLED_FORCE_INLINE Derived log2_fp(Derived x)
Definition base.h:344
static FASTLED_FORCE_INLINE Derived exp2_fp(Derived x)
Definition base.h:408

References fl::exp(), exp2_fp(), FASTLED_FORCE_INLINE, and log2_fp().

+ Here is the call graph for this function: