Binary Arithmetic - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Binary Arithmetic

Description:

Binary Arithmetic. Addition. Add 2 digits sum & carry. 7 5 2 7. 0 9 1 2 ... 3. Do the following signed binary arithmetic. Use 2's complement when appropriate. ... – PowerPoint PPT presentation

Number of Views:1130
Avg rating:3.0/5.0
Slides: 15
Provided by: mah138
Category:

less

Transcript and Presenter's Notes

Title: Binary Arithmetic


1
Binary Arithmetic
2
Addition
  • Add 2 digits ? sum carry
  • 7 5
  • 2 7
  • ------ ------
  • 0 9 1 2
  • carry sum
    carry sum

3
Binary Addition
  • Adding Binary Digits
  • a b sum a b carry
  • ------------------ -----------------
  • 0 0 0 0 0 0
  • 0 1 1 0 1 0
  • 1 0 1 1 0 0
  • 1 1 0 1 1 1
  • Sum Digit1 XOR Digit2
  • Carry Digit1 AND Digit2

4
Binary Addition
Half Adder
Full Adder
Multiple bit adder
5
Example
  • Decimal Addition
  • 5 6 11
  • Binary Addition
  • 00101 5
  • 00110 6
  • --------------
  • 01011 11

6
Binary Subtraction
  • Decimal Subtraction
  • 20 3 20 (-3)
  • Binary Subtraction
  • 20 100100
  • -3 ? Twos Complement of Binary
    representation of 3

7
Twos Complement
  • Ones Complement
  • Convert 0 to 1, and 1 to 0
  • What is Ones complement of 00011001?
  • It is 11100110
  • Twos Complement
  • Add 1 to the ones complement
  • What is the Twos complement of 00011001?
  • It is 11100111

8
Twos Complement
  • (-1) (1111)
  • (-2) (1110)
  • (-3) (1101)
  • .
  • .

9
  • In a n bits register ? unsigned numbers in the
    range of .
  • In a n bits register ? signed numbers in the
    range of .

10
Binary Subtraction
  • Decimal Subtraction
  • 20 3 20 (-3) 17
  • Binary Subtraction
  • 20 10100
  • (-3) 01101
  • -------------------------
  • 10001 17

11
Unsigned Binary Addition Example
4 bit numbers can represent numbers from 0 to 15
The result 18 is not in the range 0,15, And is
too big. Consequently, Overflow happens here. So
the carry bit from adding the two most
significant bits represents a results that
overflows.
12
Signed Binary Addition Example
signed 4 bit numbers (2's complement) can
represent numbers between -8 and 7
The extra carry from the most significant bit has
no meaning
13
Signed Binary Addition Example
signed 4 bit numbers (2's complement) can
represent numbers between -8 and 7
if two numbers with the same sign (either
positive or negative) are added and the result
has the opposite sign, an overflow has occurred.
14
Midterm Examples
  • 3. Do the following signed binary arithmetic.
    Use 2's complement when appropriate. V bit is
    Overflow and C bit is Carry
  • a) X 7, Y 2, Z X Y
  • b) X 7, Y 2, Z X - Y
  • c) X 2, Y 7, Z X - Y
Write a Comment
User Comments (0)
About PowerShow.com