FastLED 3.10.6
Loading...
Searching...
No Matches

◆ ldexp_loop_()

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

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

704 {
705 if (value == F(0)) return value;
706 if (exp == 0) return value;
707 if (exp > 0) {
708 // Cap to avoid pathological loops; saturate to ±inf-ish via overflow
709 // (these magnitudes are well outside the IEEE 754 finite range, and
710 // returning a saturated value matches libm's behavior of producing
711 // ±HUGE_VAL on overflow).
712 if (exp > 1024) exp = 1024;
713 while (exp >= 30) { value *= F(1073741824); exp -= 30; } // 2^30
714 while (exp > 0) { value *= F(2); --exp; }
715 return value;
716 }
717 // exp < 0
718 int neg = -exp;
719 if (neg > 1024) neg = 1024;
720 while (neg >= 30) { value *= F(1.0 / 1073741824.0); neg -= 30; }
721 while (neg > 0) { value *= F(0.5); --neg; }
722 return value;
723}
constexpr int type_rank< T >::value
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NO_EXCEPT

References fl::exp(), fl::FL_NO_EXCEPT, 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: