I am trying to understand this answer here.
How do both these 0xf2 and 0xfffffff2 values represent -14? Can you elaborate with the conversion process?
I know what is Two’s complement, though.
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 first bit is sign-bit. So sign is minus. To get actual value, take 2’s compliment.
Similarly, take
0xfffff...f2. Sign bit at the beginning. Take 2’s complement.Any number of preceding
1111...wouldn’t make a difference to the value of a negative signed number, just as0000..wouldn’t for positive values.The above calculation is for
8-bit signed 0xf2against32-bit signed 0xfffffff2which are both mathematically equal.