I'm not sure how to check if a double is a power of 2. This is my code so far:
double x = Double.longBitsToDouble(
Double.doubleToRawLongBits(n) & Double.doubleToRawLongBits(n - 1)
);
I used the following formula to find if the number is a power of 2:
n & (n - 1) == 0
But its not working.