Not quite. let me try to break down where im getting confused.
Lets go back to the original example
-
int input; // the user input value
-
input&= ~1;
-
lets assume that the user inputs in 349
in binary 101011101
now if the tilda inverts all bits we are going to get 0's straight across if we and them.
010100010 //
101011101 //user value
-----------------
000000000
so I'm guessing that ~1 specifies what bit is to be inverted.
so if is &= ~1 we and the value below.
111111110 // this was specified by the & ~(1)
101011101 //user value
----------------
101011100
now using the same number above but input &= ~2;
do we get . . .
111111110 // invert the last 2 bits?
101011101 //user value
----------------
101011100
am i close?