Introduction to Computer Science - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Introduction to Computer Science

Description:

Introduction to Computer Science Dr. Nagy Ramadan E-mail: Nagyrdo_at_yahoo.com Lecture - 4 Outline Part 1 - Binary Addition Part 2 - Binary Subtraction Part 3 ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 15
Provided by: Nag109
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Computer Science


1
Introduction to Computer Science
Dr. Nagy Ramadan
E-mail Nagyrdo_at_yahoo.com
Lecture - 4
2
Outline
  • Part 1 - Binary Addition
  • Part 2 - Binary Subtraction
  • Part 3 - Subtraction Using the Complement Method
  • Part 4 - Decimal Subtraction using 9s and 10s
    Complement
  • Part 5 - Binary Subtraction using 1s and 2s
    Complement

3
Binary Addition
  • Rules for binary addition are
  • 0 0 0
  • 0 1 1
  • 1 0 1
  • 1 1 0 with 1 to carry for the next
    column
  • 1 1 1 1 with 1 to carry for the
    next column

Ex 1 Find the sum of the binary numbers 1101
110 and verify the result using
decimal numbers Solution
(10011)2 124 023 022 121 120
(19)10
4
  • Ex2 Perform the following binary addition
    operation then verify the result using decimal
    numbers 110101.101 10110.111
  • Solution

(1001100.1)2 126 123 122 12-1
64 8 4 0.5
(76.5)10
5
Binary Subtraction
  • Rules for binary subtraction are
  • 0 0 0
  • 1 0 1
  • 1 1 0
  • 0 1 1 , with 1 borrowed from the next column

Ex 1 Use the direct binary subtraction to get
the result of 1100101 100111
Verify the result in decimal system. Solution
(10011)2 124 121 120 (19)10
6
Subtraction Using the Complement Method
  • The complement method allows performing
    binary subtraction in the form of binary addition
    which is much easier. This greatly simplifies the
    design of the electronic circuits of the digital
    computers.
  • Examples
  • Decimal Subtraction using 9s and 10s Complement
  • Binary Subtraction using 1s and 2s Complement

7
Decimal Subtraction using 9s and 10s Complement
Ex 1 Decimal subtraction using 9s complement
Solution
The number 6832 is the 9s complement of 3167
8
Ex 2 Decimal subtraction using 10s complement
Solution
The 10s complement the 9s complement 1
The number 6833 is the 9s complement 1 of the
number 3167. Therefore, it is called the 10s
complement.
9
Binary Subtraction using 1s and 2s Complement
  • The 1s complement of a binary number is simply
    obtained by replacing every 1 by 0 , and every 0
    by 1.
  • The 2s complement of a binary number can be
    obtained in two ways
  • By adding 1 to the 1s complement.
  • Start the binary number from right. Leave the
    binary digits unchanged until the first 1 appear,
    then replace every 1 by 0 , and every 0 by 1.

10
Ex 1 Obtain the twos complement of the binary
number 1011010.110
First solution
Second solution
11
Ex 2 Calculate the following binary
Subtraction 11101.101 1011.11 ,
then verify the result in decimal System.
Solution
(10001.111)2 16 1 0.5 0.125 (17. 875)10
12
Important Note
  • When using the complement methods in subtraction
    and having no additional 1 in the extreme left
    cell, then , this means a negative result.
  • In this case, the solution is the negative of
    1s complement of the result (if using 1s
    complement initially), or the negative of 2s
    complement of the result (if using 2s complement
    initially).

13
Ex 2 Calculate the following binary
Subtraction 1101.101 11011.11 ,
then verify the result in decimal System.
Solution
Therefore, the result - (the 1s complement of
10001.110) - 01110.001
Or - ( the 2s complement of 10001.111
) - 01110.001
14
Questions
Write a Comment
User Comments (0)
About PowerShow.com