Tom Kelliher, CS 220
Oct. 13, 1997
Finish reading Chapter 5. Homework handout.
Examples. Add the unsigned binary numbers 10111110 and 00010011. Add 01111111 and 00000001.
Idea: a modular one-bit adder.
What are the inputs? The outputs?
The rule to be satisfied:

Truth table for binary addition:

Alternate ways of viewing the outputs?
A one-bit adder:

A four-bit adder from four one-bit adders:

Addition can be pretty slow. Some useful definitions:


Carry-Lookahead Equations:

Compare to the text.
Addition algorithm for a plus b:
if a and b are of the same sign
{
sign of sum = sign of a;
magnitude of sum = magnitude of a + magnitude of b;
}
else if magnitude of a > magnitude of b
{
sign of sum = sign of a;
magnitude of sum = magnitude of a - magnitude of b;
}
else
{
sign of sum = sign of b;
magnitude of sum = magnitude of b - magnitude of a;
}
How do we handle subtraction?
Comparison slows this. Can we speed it up?
When can overflow occur? How do we detect it?
positions.
.