4 ms·
Rust has methods for these. Most C/C++ compilers have some variation on __builtin_cttz or the like. C++20 adds templated methods rather than builtins in the <b
by jcranmer 5y ago
Rust has methods for these.
Most C/C++ compilers have some variation on __builtin_cttz or the like. C++20 adds templated methods rather than builtins in the <bit> header.
Java has Integer.bitCount, Integer.numberOfLeadingZeros, etc. since Java 5.
I haven't looked at Go, Swift, D, Zig, Nim, etc., but I suspect that all of them will have some variation on this theme.