-1 can be represented in 4 bit binary as (2’s complement) 1111
15 is also represented as 1111.
So, how does CPU differentiate between 15 and -1 when it gets values from memory?
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 CPU doesn’t care whether a byte holds -1 or 15 when it moves it from one place to another. There’s no such thing as a “signed move” (to a location of the same size – there is a signed move for larger or smaller destinations).
The CPU only cares about the representation when it does arithmetic on the byte. The CPU knows whether to do signed or unsigned arithmetic according to the op-code that you (or the compiler on your behalf) chose.