Binary Addition and Subtraction

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Binary Addition

▪ It is a key for binary subtraction, multiplication, division. There are


four rules of binary addition.

▪ In fourth case, a binary addition is creating a sum of (1 + 1 = 10)


i.e. 0 is written in the given column and a carry of 1 over to the
next column.

Example − Addition

00011010 + 00001100 = 00100110 1 1 carries

0 0 0 1 1 0 1 0 = 26(base 10)

+ 0 0 0 0 1 1 0 0 = 12(base 10)

0 0 1 0 0 1 1 0 = 38(base 10)
00010011 + 00111110 = 01010001 1 1 1 1 1 carries

0 0 0 1 0 0 1 1 = 19(base 10)

+ 0 0 1 1 1 1 1 0 = 62(base 10)

0 1 0 1 0 0 0 1 = 81(base 10)

Binary Addition Examples


Here are some examples of binary addition. These are computed without regard to the word size, hence
there can be no sense of "overflow." Work through the columns right to left, add up the ones and
express the answer in binary. The low bit goes in the sum, and the high bit carries to the next column
left.

• 10001 + 11101 = 101110: • 101101 + 11001 = 1000110: • 1011001 + 111010 =


10010011:
1 1 1 1 1 1
1 1 1 1
1 0 0 0 1 1 0 1 1 0 1
1 0 1 1 0 0 1
+ 1 1 1 0 1 + 1 1 0 0 1
+ 1 1 1 0 1 0
1 0 1 1 1 0 1 0 0 0 1 1 0
1 0 0 1 0 0 1 1

• 1110 + 1111 = 11101: • 10111 + 110101 = 1001100: • 11011 + 1001010 =


1100101:
1 1 1 1 1 1 1 1
1 1 1
1 1 1 0 1 0 1 1 1
1 1 0 1 1
+ 1 1 1 1 + 1 1 0 1 0 1
+ 1 0 0 1 0 1 0
1 1 1 0 1 1 0 0 1 1 0 0
1 1 0 0 1 0 1
Eight-Bit Binary Addition Examples

Here are some examples of binary addition performed on eight-bit unsigned numbers. There's no deep
trick here — just fill out each number to eight bits, and force the sum to fit as well. If it does not fit, this
is considered an “overflow,” and will be accompanied by a one bit carried out of the 128's place, a
“carryout.” With unsigned numbers, overflow and carryout always occur together, though this is not
true for two's complement additions.

• 1011 + 10010 = 11101: • 1010110 + 110100 = • 11001011 + 1011010 =


10001010: 100100101:
1
1 1 1 1 1 1 1 1 1
0 0 0 0 1 0 1 1
0 1 0 1 0 1 1 0 1 1 0 0 1 0 1 1
+ 0 0 0 1 0 0 1 0
+ 0 0 1 1 0 1 0 0 + 0 1 0 1 1 0 1 0
0 0 0 1 1 1 0 1
1 0 0 0 1 0 1 0 0 0 1 0 0 1 0 1
No overflow. Sum is correct.
No overflow. Sum is correct. Overflow. The carry-out is
discarded, and the sum is not
correct

• 1010001 + 11001 = • 110001 + 11100100 = • 10011011 + 1001010 =


1101010: 100010101: 11100101:

1 1 1 1 1 1 1 1

0 1 0 1 0 0 0 1 0 0 1 1 0 0 0 1 1 0 0 1 1 0 1 1

+ 0 0 0 1 1 0 0 1 + 1 1 1 0 0 1 0 0 + 0 1 0 0 1 0 1 0

0 1 1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 1 1 0 0 1 0 1

No overflow. Sum is correct. Overflow. The carry-out is No overflow. Sum is correct.


discarded, and the sum is not
correct
Binary Subtraction
Subtraction and Borrow, these two words will be used very frequently
for the binary subtraction. There are four rules of binary subtraction.

Example − Subtraction

00100101 - 00010001 = 00010100 0 borrows

0 0 1 10 0 1 0 1 = 37(base 10)

- 0 0 0 1 0 0 0 1 = 17(base 10)

0 0 0 1 0 1 0 0 = 20(base 10)

00110011 - 00010110 = 00011101 0 10 1 borrows

0 0 1 1 0 10 1 1 = 51(base 10)

- 0 0 0 1 0 1 1 0 = 22(base 10)

0 0 0 1 1 1 0 1 = 29(base 10)
Other Examples

(i)101 from 1001

Solution:

101 from 1001

1 Borrow

1001

101

100

ii) 111 from 1000

Solution:

111 from 1000

1 Borrow

1000

111

0001

iii) 1010101.10 from 1111011.11

Solution:

1010101.10 from 1111011.11

1 Borrow

1111011.11

1010101.10

100110.01
iv) 11010.101 from 101100.011

Binary Subtraction Examples


Here are some examples of binary subtraction. These are computed without regard to the word
size, hence there can be no sense of "overflow" or "underflow". Work the columns right to left
subtracting in each column. If you must subtract a one from a zero, you need to “borrow” from
the left, just as in decimal subtraction.

• 1011011 − 10010 = 1001001: • 1010110 − 101010 =


101100:

0 0 • 1000101 − 101100 =
1 0 1 1 0 1 1 11001:
×1 10 ×1 10 1 1 0
− 1 0 0 1 0 0 1 1
− 1 0 1 0 1 0
1 0 0 1 0 0 1 ×1 ×10 ×10 10 1 0 1
1 0 1 1 0 0
− 1 0 1 100

1 1 001

• 100010110 − 1111010 = • 101101 − 100111 = 110: • 1110110 − 1010111 =


10011100: 11111:
0 10
0 1 1 1 10 0 10 1 10 10
1 0 ×1 ×1 10 1
×1 ×10 ×10 ×10 ×1 10 1 1 0 1 ×1 ×1 ×10 ×1 ×1 10
− 1 0 0 1 1 1
− 1 1 1 1 010 −10 1 0 1 1 1
1 1 0
1 0 0 1 1 100 1 1 1 1 1

You might also like