I have 1 bit in a byte (always in the lowest order position) that I\'d like to invert. ie given 00000001 I\'d like to get 00000000 and with 00000000 I\'d like 00000
byte
Your solution isn't correct because if bit == 2 (10) then your assignment will yield bit == 0 (00).
This is what you want:
bit ^= 1;