Binary subtraction with numbers in 2's complement How can i perform binary subtraction of two numbers that are already in 2's complement?
I have to subtract 01010011 from 10100110,both numbers are in 2's complement.
I know that 10100110 is -90,and 01010011 is 83,so the result should be -173.
So if i use 8 bits that means that there's overflow.
But i don't get how can i perform the subtraction when both the numbers are in 2's complement.
If i just perform the subtraction i get the same number 01010011. How do i show the result and that there's overflow?
You cannot represent –173 using 8 bits, since the range is –128 to 127.
To subtract two numbers in two's complement, you use the identity $a - b = a + (-b)$. In your case, $a = 10100110$, $b = 01010011$, and $-b = 10101101$. Adding $a$ and $-b$, there is overflow, so you know that the number is outside the range.