isPowerOfTwo method
Returns true if n
is a power of 2.
Implementation
static bool isPowerOfTwo(int n) {
if ((n & (n - 1)) == 0) return true;
return false;
}
Returns true if n
is a power of 2.
static bool isPowerOfTwo(int n) {
if ((n & (n - 1)) == 0) return true;
return false;
}