0

I know for $2's$ complement representation, you are supposed to perform an operation like $A - B$ into addition but perform $2's$ complement on $B$.

So $0101 - 1001 = 0101 + 0111$

Now, if I had a question in the form of $-A - (-B)$, would I combine the signs and it would become $-A + B$, or would I do $2's$ complement on $-B$ and get $-A - B$?

Valent
  • 3,228
  • 1
  • 15
  • 28

1 Answers1

1

Having $n$ digits in $2$s complement representation we define complement of number $A$, between $1$ and $2^n-1$, by formula $-A=2^n-A$.

So $-A - (-B)$ is same with $-A +B$: $$-A - (-B) = 2^n-A +(2^n- (2^n-B)) = 2^n-A+B=-A +B$$

zkutch
  • 13,410