FastLED 3.9.15
Loading...
Searching...
No Matches

◆ abs()

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

Absolute value: branchless via mask and xor.

Definition at line 81 of file s16x16x4.h.

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

References FASTLED_FORCE_INLINE.