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

◆ isqrt32_floor()

fl::i32 fl::gfx::detail::isqrt32_floor ( fl::i32 n)
inline

Integer square root using digit-by-digit algorithm Computes floor(sqrt(n)) for positive integers Uses only shifts, adds, and comparisons — no division.

Definition at line 12 of file integer_math.h.

12 {
13 if (n <= 0) return 0;
14 fl::u32 un = (fl::u32)n;
15 fl::u32 result = 0;
16 fl::u32 bit = 1u << 30; // highest even power of 2
17 while (bit > un) bit >>= 2; // find starting magnitude
18 while (bit != 0) {
19 fl::u32 t = result + bit;
20 result >>= 1;
21 if (un >= t) { un -= t; result += bit; }
22 bit >>= 2;
23 }
24 return (fl::i32)result;
25}
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References fl::t.