int main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
return 0;
}
a. 0, 0
b. 0, 513 c. 512, 0 d. 0, -513Guys I am not having the answer of this question and also not able to interpret the question.so could you please provide your answers with proper explanation.
The correct answer is d: http://ideone.com/frKOz
- bit is 0 because
bit & ~bit
always results in a zero (1000000000 & 0111111111
). - mbit is -513 because inverting 512 is -513.
Edit: Why is mbit
-513?
See explanation of signed-integer-handling: http://www.rwc.uc.edu/koehler/comath/13.html
精彩评论