Showing posts with label subtraction of binary numbers. Show all posts
Showing posts with label subtraction of binary numbers. Show all posts

Friday, January 27, 2012

Binary subtraction


Binary subtraction

Before explaining subtraction lets see how negative numbers are represented in binary. To denote the sign of a binary number a extra bit is used in the left end of the number. By convention zero is used to represent + sign and a one is used to represent -sign.

+5 = 0,101
-7 = 1,111

Subtraction is the process of adding a negative number to a positive number. If a number having a positive sign is added to a number with a number y having a negative sign ,it is equivalent to subtracting y from x.

Consider the example below
101-011

Borrow
1
0

Minuend
1
0
1
Subtrahend
0
1
1
Difference
0
1
0


Borrow
0
Minuend
0
Subtrahend
0
Difference
0

Borrow
1
Minuend
0
Subtrahend
1
Difference
1

From the above examples we can construct a half subtracter table and full subtracter table.



Half subtracter

a
b                                       Difference             Borrow
0
0
0
0
0
1
1
1
1
0
1
0
1
1
0
0

Full subtracter

A(Minuend)
B(Subtrahend)
Borrow
Difference
Borrow to next position
0
0
0
0
0
0
0
1
1
1
0
1
0
1
1
0
1
1
0
1
1
0
0
1
0
1
0
1
0
0
1
1
0
0
0
1
1
1
1
1