# Subtract Binary Numbers with 1s Complement

I'm trying to figure out how to subtract two binary numbers with a complementary one or two, When I need to address carrier and when not? Do I need to solve the problem in decimal numbers? And simultaneously see the answer in binary numbers? For example:

(10101010) - (1101101)
complement of (1101101) is 0010010
then i take the first number and add it to the complement
10101010+
0010010
_______
10111100

the result of subtraction those number is : 111101 so what im understanding is i have
a carrier so im take 111100 + 1 and i get the final result : 111101


now Ill take another two numbers

(111001) - (10011)


im doing the same procces and i dont get the right answer. what should i do? Do I need to complete the number to the eight bits? That is if you need to add zeros then the complement they will become one?
Thanks!

$10101010 - 1101101 = 10101010 - 01101101 = 10101010 + (-01101101)= 10101010 + (10010010 + 1)=10101010 + 10010011 = 00111101$

And you can check that $00111101+1101101=10101010$

$111001 - 10011 = 00111001 - 00010011 = 00111001 + (-00010011) = 00111001 + (11101100 + 1) = 00111001 + 11101101 = 00100110$

And you can check that $00100110+10011=111001$

So to compute $a-b$, you start by making sure you have $8$ bits for both numbers and add $0$s on the left otherwise, then you compute $-b$ by negating all the bits and adding $1$ and then you compute $a+(-b)$.

• there is a difference between 2s and 1s? , in 2s im adding one and flip, and 1s im just flipping? – Ofir Attia Mar 28 '13 at 12:20
• Yes and no. You flip before adding $1$. – xavierm02 Mar 28 '13 at 12:31

You cannot add by just taking complement of a number.First you have to convert negative number into 2's complement.

2's complement

First take complement

`

a=(010101010) - b=(001101101)

2's complement of b is 110010011

now $a+b^{'}$

a= 010101010 (170)

$b^{'}$=110010011 (-109)

c= 000111101 (61)

• alternative way of finding 2's complement is $2^n-b$ where n is number of bits.for example:- 10011 here n=5 so calculate $32-19$=13 and write 13 into binary form 01101(2's complement of 10011) – TLE Mar 28 '13 at 12:29