Signed Binary Addition and Subtraction
Tom Kelliher, CS 220
Oct. 13, 2003
Read 3.13
Exam.
- Complements.
- Subtraction using 2's complement.
- Signed numbers.
- Combined 2's complement adder/subtractor.
VHDL.
Used for signed representations.
- Diminished radix complement: 1's complement.
- The 1's complement of an n bit binary number A is .
- What's the bit representation of ? The one's complement
of A? A plus its one's complement?
- Radix complement: 2's complement.
- The 2's complement of an n bit binary number A is .
- 1's complement plus one.
Two's complement of A? A plus its two's complement?
Subtract by adding!
Adding works the same.
- Denote the 2's complement of B as .
Recall .
- .
Note we should get a carry out of the msb when we perform .
- Work the two examples again.
Skip sign-magnitude representation.
- The Complement (1's, 2's) of a number is its additive identity.
Well, almost. What's the 1's complement of 0? In 1's complement, what
does a number and its complement add to?
- Msb is sign bit. Weight of sign bit. 2's complement: .
1's complement: .
Bit patterns for: most positive number, most negative number, 1, -1.
- Range:
- 2's complement
- 1's complement
For six bit numbers, what is the range of:
- Unsigned integers.
- 1's complement integers.
- 2's complement integers.
In 1's and 2's complements, what are the representations of 15, -18, 27, -4,
33, -32, -35, 10?
- 2's complement: invert bits, add one.
- EXOR gate can be used as a conditional inverter.
- We're not using for anything.
Computes A + B or A - B.
Thomas P. Kelliher
Mon Oct 13 11:39:05 EDT 2003
Tom Kelliher