Signed Binary Addition and Subtraction

Tom Kelliher, CS 220

Oct. 13, 2003

Administrivia

Announcements

Assignment

Read 3.13

From Last Time

Exam.

Outline

  1. Complements.

  2. Subtraction using 2's complement.

  3. Signed numbers.

  4. Combined 2's complement adder/subtractor.

Coming Up

VHDL.

Complements

Used for signed representations.

  1. Diminished radix complement: 1's complement.
    1. The 1's complement of an n bit binary number A is .

    2. What's the bit representation of ? The one's complement of A? A plus its one's complement?

  2. Radix complement: 2's complement.
    1. The 2's complement of an n bit binary number A is .

    2. 1's complement plus one.

      Two's complement of A? A plus its two's complement?

Subtraction Using 2's Complement

Subtract by adding!

Adding works the same.

  1. Denote the 2's complement of B as .

    Recall .

  2. .

    Note we should get a carry out of the msb when we perform .

  3. Work the two examples again.

Signed Numbers

Skip sign-magnitude representation.

  1. 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?

  2. 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.

  3. Range:
    1. 2's complement

    2. 1's complement

Practice

For six bit numbers, what is the range of:

  1. Unsigned integers.

  2. 1's complement integers.

  3. 2's complement integers.

In 1's and 2's complements, what are the representations of 15, -18, 27, -4, 33, -32, -35, 10?

A 2's Complement Combined Adder/Subtractor

  1. 2's complement: invert bits, add one.

  2. EXOR gate can be used as a conditional inverter.

  3. 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