Is An Integer A Power Of Two?
Java:
boolean power2(int x) {
return x != 0 && (x & (x - 1)) == 0;
}
A power of two must be greater than zero.
Java:
boolean power2(int x) {
return x != 0 && (x & (x - 1)) == 0;
}
A power of two must be greater than zero.