I want to find the power of 2 that any integer contains. Like 12 = 2*2*3 so answer should come as 2, 28 = 2*2*7 so answer should come as 2 and so on.
int powerOf2InNumber = (int)Math.floor(Math.log(number) / Math.log(2));
I tried the above code but in cases like 28,26,10 etc i'm getting wrong answer.