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

◆ ldexp_loop_()

template<typename F>
F fl::detail::ldexp_loop_ ( F value,
int exp )
inline

Definition at line 623 of file math.cpp.hpp.

623 {
624 if (value == F(0)) return value;
625 if (exp == 0) return value;
626 if (exp > 0) {
627 // Cap to avoid pathological loops; saturate to ±inf-ish via overflow
628 // (these magnitudes are well outside the IEEE 754 finite range, and
629 // returning a saturated value matches libm's behavior of producing
630 // ±HUGE_VAL on overflow).
631 if (exp > 1024) exp = 1024;
632 while (exp >= 30) { value *= F(1073741824); exp -= 30; } // 2^30
633 while (exp > 0) { value *= F(2); --exp; }
634 return value;
635 }
636 // exp < 0
637 int neg = -exp;
638 if (neg > 1024) neg = 1024;
639 while (neg >= 30) { value *= F(1.0 / 1073741824.0); neg -= 30; }
640 while (neg > 0) { value *= F(0.5); --neg; }
641 return value;
642}
constexpr int type_rank< T >::value
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NOEXCEPT

References fl::exp(), FL_NOEXCEPT, and fl::type_rank< T >::value.

Referenced by fl::ldexp_impl_double(), and fl::ldexp_impl_float().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: