Detect if a number is power of 2 using bitwise operators

Reading time: 15 minutes | Coding time: 1 minutes

Bitwise operators are one of the most under-rated operators in C/C++, despite being quite fast as most of the processors today have direct support for bit level operators.

This is a companion discussion topic for the original entry at