When I was trying to learn from an existing program, I could not understand what the following two lines of code try to do?
for(i=0;0==(x&1);++i)x>>=1;
if(0==(x-=y)) return y<<i;
Any explanations would be appreciated.
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.
Finds the least significant bit set to
1in an integerSubtracts
yfromx, and if the result is 0, returnsyshifted over (toward the more significant bits) byibits.