binary subtraction wrong result

139 Views Asked by At

I am trying to compute: 1000001 - 11011 The way I approach this is convert 11011 to 1's complement to 00100 and then add 1, having finally 00101. However if I do 1000001 + 101 it gives me 1000110, but if i check with an online calculator it says is wrong as the result should be 100110.

2

There are 2 best solutions below

1
On BEST ANSWER

$1000001 - 0011011 = 1000001 + 1100101 = 0100110$

Note that I extended the second number to seven bits so that the bit count was equal. Only then did I convert it through $1$'s complement

0
On

Another way is to do subtraction like you learned in grade school $$ \begin {align}1000001_2&\\ \underline{ -11011_2}&\\100110_2& \end {align}$$ where you borrow from the left whenever needed.