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

◆ signedCbrtQ16()

i32 fl::anonymous_namespace{oklab_q16.cpp.hpp}::signedCbrtQ16 ( i32 raw)

Signed cube root of an s16.16 raw value.

For a raw r standing for r/2^16, the root y satisfies (y/2^16)^3 = r/2^16, so y^3 = r * 2^32 – the integer cube root of the raw shifted left by 32. The magnitude is taken through i64 because negating INT32_MIN in 32 bits is undefined.

Definition at line 89 of file oklab_q16.cpp.hpp.

89 {
90 const i64 magnitude = raw < 0 ? -static_cast<i64>(raw) : static_cast<i64>(raw);
91 const i32 root = static_cast<i32>(
92 fl::icbrt64(static_cast<u64>(magnitude) << 32));
93 return raw < 0 ? -root : root;
94}
FL_OPTIMIZE_FUNCTION constexpr u32 icbrt64(u64 x) FL_NO_EXCEPT
Definition icbrt.h:45
fl::u64 u64
Definition stdint.h:220
fl::i64 i64
Definition stdint.h:221

References fl::FL_NO_EXCEPT, fl::icbrt64(), and signedCbrtQ16().

Referenced by signedCbrtQ16().

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