Subtract Two Negative Binary Numbers

7.6k Views Asked by At

Given the example (in decimal) -32 - (-16), how would this be done in binary? Would you simply add their complements together or would you need to use their two's complement, or?...

I'd appreciate it if you could provide a visual, step-by-step, to help me wrap my head around it and try to help me understand the logic behind each step.

1

There are 1 best solutions below

2
On BEST ANSWER

For demonstration purpose, I am using $8$-bit $2$'s complement representation of the given numbers. We have $-32_{10} = \color{red}{1}1100000_2$ and $-16_{10} = \color{red}{1}1110000_2$. Here, the most-significant bit (shown in red) carries a weight of $-128$. Since $a-b = a+(-b)$, we add the $2$'s complement of $b$ to $a$. Now, $2$'s complement of $\color{red}{1}1110000_2$ is $\color{red}{0}0010000_2$. Therefore, $$-32_{10}-(-16_{10}) = \color{red}{1}1100000_2+\color{red}{0}0010000_2 = \color{red}{1}1110000_2 =-16_{10}.$$