0
$\begingroup$


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 i`m understanding is i have a carrier so i`m take 111100 + 1 and i get the final result : 111101 

now I`ll take another two numbers

(111001) - (10011) 

i`m 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!

$\endgroup$

2 Answers 2

2
$\begingroup$

$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)$.

$\endgroup$
2
  • $\begingroup$ there is a difference between 2s and 1s? , in 2s im adding one and flip, and 1s im just flipping? $\endgroup$ Commented Mar 28, 2013 at 12:20
  • $\begingroup$ Yes and no. You flip before adding $1$. $\endgroup$ Commented Mar 28, 2013 at 12:31
0
$\begingroup$

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 add 1 to flipped number 

a=(010101010) - b=(001101101)

2's complement of b is 110010011

now $a+b^{'}$

a= 010101010 (170)

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

c= 000111101 (61)

$\endgroup$
1
  • $\begingroup$ 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) $\endgroup$ Commented Mar 28, 2013 at 12:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.