I'm trying to check the number of set bits is 2 or more in negation of number. I'm trying to do that with checking if number is power of 2. But it's not working with negation of number. This is my code:
unsigned long int x = ~x; //x is given number
if(!(x & (x - 1))) printf("it have only one set bit);
Do you have any sugestion?