isPowerOf2 static method

bool isPowerOf2(
  1. int n
)

Checks if n is potĂȘncia de 2

Implementation

static bool isPowerOf2(int n) {
  if (n <= 0) return false;
  return (n & (n - 1)) == 0;
}