I have this integer int nine = 9; which in binary is 1001. Is there an easy way to invert it so I can get 0110 ?
int nine = 9;
1001
0110
There's an operator specifically for it, ~.
~
nine = ~nine;