I have integer variable a and another integer variable p. p is position. I want to flip the integer bite at position p. If the bit which is at position pof the variable a is 0 I want to change it to 1 and if the bit which is at position pof the variable a is 1 I want to change it to 0. How can I do it? I am writing it in Java but explanation in any language is fine.
Asked
Active
Viewed 25 times
0
-
See "toggle". That was a C++ question but that doesn't really matter in this case. – harold Sep 24 '17 at 15:15
-
Thanks @harold it worked! – Sep 24 '17 at 15:24