Binary Adder/Subtractors

Index, Next

Why not Subtractors

Subtraction and addition are intertwined, so pure subtractors are not common.

How can we perform subtraction with an adder?

Negate the subtrahend... add (12 -7 = 12 + (-7))

Look at ways to represent signed binary numbers:

Signed magnitude - most significant bit used for "minus sign"
2's complement
1's complement

Signed Magnitude

Most significant bit is set to 1 for negative numbers:

5 is 00101
and -5 is 10101

2 cases when subtracting:

Positive result Negative result
1101 0110
-0110 - 1101
------- -------
0111 1001
-10000
=======
-0111
No carry from the most significant bit... means positive result and we're done
Most significant carry... means that the result is negative, subtract 2n

There might be an easier way

2's Complement

In general: R's complement to a radix R number is:

The most significant bit equals -(2n)
Remaining bits normal binary value

Examples:

Example 1:

01001

= 8 + 1

= 9

Example 2:

10110

= -16 + 4 + 2

= -10

With 2's complement the negative of a number is the bit-wise complement plus one:

Example: 00110 = 6

What is -6?

Bit-wise complement + 1

11001 + 1 = 11010

11010

= -16 + 8 + 2

= -6

Now, let's subtract using 2's complement representation:

Example: 2's complement, positive result
45
- 19
========
26
101101
- 010011
========
 
2's comp -->
0101101
+ 1101101
========
0011010
Check: 0011010 = 16+8+2 = 26... ok

 

Example: 2's complement, negative result
19
- 45
========
-26
010011
- 101101
========
 
2's comp -->
0010011
+ 1010011
========
1100110
Check: 1100110 = -64+32+4+2 = -26... ok

General algorithm when subtracting with 2's complement:

If carry into the most significant, then results is positive and you're done
If no carry, then result is the correct 2's complement negative answer

1's Complement

Generally case is called "Radix diminished complement" for radix R numbers.

Most significant bit equals (2n -1)
Remaining bits have normal binary value

Biggest change from 2's complement. Negating a number is simple: take the bit-wise complement.

Example: 00110 = 6

What is -6?

Take Bit-wise complement

11001

= -15 + 8 + 1

= -6

Ok, subtract using 1's complement:

Example: 1's complement, positive result
45
- 19
========
26
101101
- 010011
========
 
1's comp -->
 
 
End around carry -->
0101101
+ 1101100 
========
0011001
+1
========
0011010
Check: 0011010 = 16+8+2 = 26... ok

 

Example: 1's complement, negative result
19
- 45
========
-26
010011
- 101101
========
 
1's comp -->
0010011
+ 1010010
========
1100101
Check: 1100110 = -63+32+4+1 = -26... ok


Algorithm:

A carry into the most significant bit is added to the result... "end-around carry"
No, end-around carry means you have the 1's complement negative answer

Summary

Compare the three methods for representing negative numbers:

Signed-magnitude - requires translation to 2's complement and back again... this means extra hardware
1's complement - better, but the "end-around carry" is an extra step in the process
2's complement - best for the subtraction process

With 1's or 2's complement adder/subtractors are the best option

2's complement is the common form used to represent negative numbers

Note: there is a table comparing the three repsentations of negative numbers from -8 to +7 on page 140 of our text.