FastLED 3.10.8
Loading...
Searching...
No Matches

◆ ldexp_loop_()

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

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

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