Docsity

Binary Arithmetic: Unsigned Addition, Subtraction, and Two's Complement - CSC201 Fall 2000, Study notes of Computer Science

Partial preview of the text

Download Binary Arithmetic: Unsigned Addition, Subtraction, and Two's Complement - CSC201 Fall 2000 and more Study notes Computer Science in PDF only on Docsity!

Binary ArithmeticBinary Arithmetic

September 22, 2000September 22, 2000

CSC201 Section 002 Fall, 2000

Unsigned Addition Unsigned Addition

  • When adding two numbers, for each bit position there are two addends, and a carry-in

3 outputs = 1 1 1

2 inputs = 1 0 1

1 input = 1 1 0

0 inputs = 1 0 0

And carry-out =

If… Then sum =

Unsigned Subtraction Unsigned Subtraction

  • Bad idea; don't do it!

Two's Complement Addition Two's Complement Addition

  • Exactly like unsigned addition, except for overflow detection
  • Doesn't matter what the sign of the inputs or output are; same operation!

Two's Complement Subtraction Two's Complement Subtraction

  • (Terminology: minuend - subtrahend)
  • Steps
    • two's-complement the subtrahend
    • then add to the minuend 0 1 1 0 1
  • 0 1 0 0 1

Unsigned Binary Multiplication Unsigned Binary Multiplication

  • Generate partial products, shift, and sum together
  • Partial product generation = AND with the multiplier bit
  • Multiplying two n-bit numbers produces a 2n-bit product

x 1 1 0 0 0 0 1 0 1

  • 1 0 1 0 1 1 1 1 0

Unsigned Division (cont.) Unsigned Division (cont.)

  • Dividing two n-bit numbers produces n-bit quotient and n-bit remainder
  • Overflow possible
    • If most significant half of dividend greater than or equal to divisor
  • Also, check for division by zero first

Two’s- Two’s-Complement MultiplicationComplement Multiplication

and Additionand Addition

  • Skip it!