int m=32
printf("%x" , ~m);
Output of this statement is ffdf and without ~ output is 20.
What is the significance of %x and ~?
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.
The
~operator is bitwise negation. It will print bitwise negation ofm‘s value.%xmeans thatprintfwill output its value in hexadecimal format.So, value
0xffdfis the negation of value0x20(32).Value 32 (int bits would be):
Its bitwise negation will be:
Which makes sense since:
And: