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

◆ abs()

FASTLED_FORCE_INLINE s16x16x4 fl::s16x16x4::abs ( ) const
inline

Absolute value: branchless via mask and xor.

Definition at line 85 of file s16x16x4.h.

85 {
86 // mask = -1 if negative (sign extended), 0 if positive
87 auto mask = simd::sra_i32_4(raw, 31);
88 // flip bits if negative, then add 1 (two's complement)
89 auto flipped = simd::xor_u32_4(raw, mask);
90 return from_raw(simd::sub_i32_4(flipped, mask));
91 }
static FASTLED_FORCE_INLINE s16x16x4 from_raw(simd::simd_u32x4 r)
Definition s16x16x4.h:28
simd::simd_u32x4 raw
Definition s16x16x4.h:24

References FASTLED_FORCE_INLINE.