Mam in the question ResetBit can we do exclusive_or with our mask having 1 at the ith bit?
Bit Manipulation
Hey Suryansh, the problem is what if the bit is already 1 or 0 and we have to reset it for the same. Your approach is right for toggling the ith bit.not resetting the ith bit.
Resetting means that if the bit is 0 then make it 1 and if it is 1 then make it 0. Right??
So for the example discussed my approach worked that is for 21 and 3rd bit the output comes to be 17.
No. this is known as toggling. resetting means you have to reset the ith bit 1 whether it is 0 or 1… or 0 whether ith bit is 0 or 1.
Oh Thank you for your help!
I just got the wrong meaning of resetting.