The most efficient way to test if a number is 2^n (i.e. 2,4,8,etc.) in C++20?
A handy method to verify if a number n
is a power of two (like 2, 4, 8, etc.) is to use the following test:
The most efficient way to test if a number is 2^n (i.e. 2,4,8,etc.) in C++20?
A handy method to verify if a number n
is a power of two (like 2, 4, 8, etc.) is to use the following test: