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

◆ exp_reduced_() [2/2]

float fl::detail::exp_reduced_ ( float x)
inline

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

125 {
126 FloatBits xb;
127 xb.f = x;
128 const u32 ax = xb.u & 0x7fffffffu;
129 if (ax >= 0x42b17218u) { // |x| >= 88.7228, or NaN
130 if (ax > 0x7f800000u) return x; // NaN
131 if ((xb.u >> 31) == 0u) { // overflow -> +inf
132 FloatBits inf;
133 inf.u = 0x7f800000u;
134 return inf.f;
135 }
136 if (ax >= 0x42cff1b5u) return 0.0f; // x <= -103.972: underflow
137 }
138 // k = round(x / ln2) via the 1.5 * 2^23 magic constant: adding it puts
139 // the integer in the low mantissa bits, so no float<->int conversions.
140 const float kMagic = 12582912.0f;
141 FloatBits t;
142 t.f = x * 1.44269504088896341f + kMagic;
143 const int k = t.i - 0x4b400000;
144 const float kf = t.f - kMagic;
145 const float r = (x - kf * 6.9314575195e-01f) - kf * 1.4286067653e-06f;
146 // e^r = 1 + r + r^2 * P(r), P minimax on |r| <= ln2/2: worst case 1 ulp.
147 float p = 1.393364297e-03f;
148 p = p * r + 8.363175565e-03f;
149 p = p * r + 4.166646498e-02f;
150 p = p * r + 1.666657700e-01f;
151 p = p * r + 5.000000013e-01f;
152 p = (p * r * r) + r + 1.0f;
153 return scale_pow2_(p, k);
154}
int x
Definition simple.h:92
static uint32_t t
Definition Luminova.h:55
float scale_pow2_(float p, int k) FL_NO_EXCEPT
Definition math.cpp.hpp:107

References fl::detail::FloatBits::f, fl::FL_NO_EXCEPT, scale_pow2_(), fl::t, fl::detail::FloatBits::u, and fl::x.

Referenced by fl::exp_impl_double(), fl::exp_impl_float(), and exp_reduced_().

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