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

◆ exp()

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

Definition at line 40 of file math.h.

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

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: