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

◆ exp_reduced_() [2/2]

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

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

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

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: