isPowerOfTwo function

bool isPowerOfTwo (int number)

Find out whether the provided integer is a perfect power of two.

True if and only if it is a power of two.

Implementation

bool isPowerOfTwo(int number) => number > 0 && (number & (number - 1)) == 0;