if(!(num & (num - 1)) && num){ // Power of 2!}
Method2if(((~i+1)&i)==i){ //Power of 2!}
if(((~i+1)&i)==i){ //Power of 2!}
Method 3
No comments:
Post a Comment