Say, I have a integer like 10101, I would like to unset the third bit to get 10001; if I have 10001, I will still get 10001; how can I achieve it?
unset(int i, int j)
int i= 10101 or 10000
int j = 00100
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that you are indexing bits from the right, this should work to unset a particular bit in
value:You can set the bit using similar code:
where
maskis as before. (This assumes that bit indexing starts at 0.)