s16.16 of a float, rounded to nearest, computed from its IEEE-754 bits with integer arithmetic only – no soft-float helper on a part without an FPU (FastLED#4458).
False for NaN, infinity or |value| >= 32768.
Definition at line 292 of file device_solve.cpp.hpp.
292 {
293 if (out == nullptr) {
294 return false;
295 }
296
297
298
299
301 const bool negative = (bits >> 31) != 0;
302 const i32 exponent = static_cast<i32>((bits >> 23) & 0xFFu);
303 const u32 fraction = bits & 0x7FFFFFu;
304 if (exponent == 0xFF) {
305 return false;
306 }
307 if (exponent == 0) {
308 *out = 0;
309 return true;
310 }
311
312
313 const u64 mantissa =
static_cast<u64>(fraction | 0x800000u);
314 const i32 shift = exponent - 134;
316 if (shift >= 0) {
317 if (shift > 7) {
318 return false;
319 }
320 magnitude = mantissa << shift;
321 } else {
322 const i32 right = -shift;
323 if (right > 40) {
324 magnitude = 0;
325 } else {
326
327
328 magnitude = (mantissa + (
static_cast<u64>(1) << (right - 1))) >> right;
329 }
330 }
331 if (magnitude > 0x7FFFFFFFull) {
332 return false;
333 }
334 *out = negative ? -static_cast<i32>(magnitude) : static_cast<i32>(magnitude);
335 return true;
336}
constexpr int type_rank< T >::value
To bit_cast(const From &from) FL_NO_EXCEPT
References bit_cast(), FL_NO_EXCEPT, and type_rank< T >::value.
Referenced by fl::anonymous_namespace{chromatic_adaptation.cpp.hpp}::adaptationWhiteQ16(), buildRgbSolveMatrixQ16(), buildStreamingPipelineQ16(), buildWhiteAllocationFromSolveQ16(), fl::anonymous_namespace{source_xyz.cpp.hpp}::sourceChromaticityQ16(), and fl::anonymous_namespace{pipeline.cpp.hpp}::wideWhiteColumnQ16().