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

◆ exp()

template<typename T>
T fl::exp ( T value)
inline

Definition at line 47 of file math.h.

47 {
48#if defined(FASTLED_HAS_EXP)
49 return static_cast<T>(::exp(static_cast<double>(value)));
50#else
51 // Fallback implementation using Taylor series approximation
52 // e^x ≈ 1 + x + x²/2! + x³/3! + x⁴/4! + x⁵/5! + ...
53 // This is a simple approximation for small values
54 double x = static_cast<double>(value);
55 if (x > 10.0)
56 return static_cast<T>(22026.465794806718); // e^10 approx
57 if (x < -10.0)
58 return static_cast<T>(0.0000453999297625); // e^-10 approx
59
60 double result = 1.0;
61 double term = 1.0;
62 for (int i = 1; i < 10; ++i) {
63 term *= x / i;
64 result += term;
65 }
66 return static_cast<T>(result);
67#endif
68}
int x
Definition simple.h:92
Result type for promise operations.
T exp(T value)
Definition math.h:47

References exp(), and x.

Referenced by exp(), and MaxFadeTracker::operator()().

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