I just learnt the concept of two's complement. It is useful in the subtraction of binary numbers. But in my college booklet i have been asked to solve 48+23 and -48-23 using 2's complement. What is the logic behind this and how to proceed with this question?
答案 0 :(得分:0)
The key insight is that negative numbers are not merely conveniently represented by two's complement, but the scheme actually preserves the properties of addition and subtraction naturally as a result of the encoding itself. That is:
These properties make working (i.e. arithmetic) using this encoding a lot easier than, say one's complement.
Finally, for a fixed length two's complement bit string, the number of available negative numbers is always exactly one larger than the number of available positive numbers.