Re:EABitTricks.h
by 10000truths on Monday December 19, 2022 @11:16AM
(#34053798)
Modern CPUs have a count-leading-zeros instruction to calculate floor(log2(x)) efficiently. GCC and clang expose this with the __builtin_clz* family of intrinsics. MSVC exposes this with _BitScanReverse.
[ Parent
| on HN ]
Re:EABitTricks.h
by vinkelhake on Monday December 19, 2022 @01:08PM
(#34055368)
And C++ (as of C++20) exposes this and more in the header <bit>.