Introduction to Computer Science

Slides:



Advertisements
Similar presentations
HEXADECIMAL NUMBERS Code
Advertisements

Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
Computer Engineering (Logic Circuits) Dr. Tamer Samy Gaafar Lec. # 2
Binary Addition Rules Adding Binary Numbers = = 1
CMP 101 Fundamentals of Computer and programming in C Rohit Khokher.
EMB1006 The Binary System There is no 2 Jonathan-Lee Jones.
Signed Numbers Up till now we've been concentrating on unsigned numbers. In real life we have to represent signed numbers ( like: -12, -45, 78). The difference.
Signed Numbers.
CSCI 232© 2005 JW Ryder1 Bases  = (3 * 10 2 ) + (2 * 10 1 ) + (4 * 10 0 )  = (3 * 8 2 ) + (2 * 8 1 ) + (4 * 8 0 )  = (1 * 2 3 )
Binary Math CS208. Decimal Addition Example ) Add = 15 Write down 5, carry ) Add = 8 Write down 8 3)
Decimal Addition What is going on? (carry) (subtract the base)
Digital Circuits. Analog and Digital Signals Noise margins in Logic Circuits VMVM.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
CSE20 Lecture 3 Number Systems: Negative Numbers 1.Sign and Magnitude Representation 2.1’s Complement Representation 3.2’s Complement Representation 1.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
1.6 Signed Binary Numbers.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Binary Addition Addition Rules: = = = = = carry 1 1 carry 1 Example 1: Example 2:
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
Number Systems Binary and Hexadecimal. Base 2 a.k.a. Binary  Binary works off of base of 2 instead of a base 10 like what we are taught in school 
Chapter 7 Arithmetic Operations and Circuits Binary Arithmetic Addition –When the sum exceeds 1, carry a 1 over to the next-more-significant column.
BINARY ARITHMETIC Binary arithmetic is essential in all digital computers and in many other types of digital systems.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Number Representation. 10/12/2015CDA31002 Conversion between Representations Now we can represent a quantity in different number representations How can.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Positional Number Systems
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
Chapter 3 Complements Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
ECE 2110: Introduction to Digital Systems
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Addition and Substraction
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
Scientific Notation Algebra Seminar. Objectives ► Write numbers in standard and scientific notation. ► Perform calculations with numbers in scientific.
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
1 4. Computer Maths and Logic 4.1 Number Systems.
NUMBER SYSTEMS.
Adding and subtracting decimal numbers Written methods.
IT1004: Data Representation and Organization Negative number representation.
ECE 362 Microprocessor Systems and Interfacing ©5-1 Lecture 1 Hexadecimal Computation Outline n Decimal n Binary n Octal n Hexadecimal.
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic Herbert G. Mayer, PSU Status 1/14/2016 Copied with Permission from prof. Mark PSU ECE.
Arithmetic in Binary. Addition A “Rule of Addition” is a statement of the form: = 8 How many such rules are there in Decimal?
Introduction to Digital Electronics Lecture 2: Number Systems.
Two’s and one’s complement arithmetic CLOCK ARITHMETIC.
©2010 Cengage Learning SLIDES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION Click the mouse to move to the next page. Use the ESC key to exit.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
COMPUTER ORGANIZATION 4 TH LECTURE. ASCII Code  ASCII ( American Standard Code for Information Interchange).  Input and output devices that communicate.
ECE 3110: Introduction to Digital Systems
CPE 201 Digital Design Lecture 3: Digital Systems & Binary Numbers (3)
Introduction To Number Systems
Chapter 3 Data Representation
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Number Representation
COMPLEMENTS Complements are used in digital computers for simplifying the subtraction operations and for logical manipulation. There are two types of complements.
Computation in Other Bases
Unit 18: Computational Thinking
CPS120: Introduction to Computer Science
Arithmetic Operation By: Asst Lec. Besma Nazar Nadhem
Presentation transcript:

Introduction to Computer Science Dr. Nagy Ramadan E-mail: Nagyrdo@yahoo.com Lecture - 4

Outline Part 1 - Binary Addition Part 2 - Binary Subtraction Part 3 - Subtraction Using the Complement Method Part 4 - Decimal Subtraction using 9’s and 10’s Complement Part 5 - Binary Subtraction using 1’s and 2’s Complement

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 = 1*24 + 0*23 + 0*22 + 1*21 + 1*20 = (19)10

Ex2: Perform the following binary addition operation then verify the result using decimal numbers: 110101.101 + 10110.111 Solution: (1001100.1)2 = 1*26 + 1*23 + 1*22 + 1*2-1 = 64 + 8 + 4 + 0.5 = (76.5)10

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 = 1*24 + 1*21 + 1*20 = (19)10

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 9’s and 10’s Complement Binary Subtraction using 1’s and 2’s Complement

Decimal Subtraction using 9’s and 10’s Complement Ex 1: Decimal subtraction using 9’s complement Solution: The number 6832 is the 9’s complement of 3167

The 10’s complement = the 9’s complement + 1 Ex 2: Decimal subtraction using 10’s complement Solution: The 10’s complement = the 9’s complement + 1 The number 6833 is the 9’s complement + 1 of the number 3167. Therefore, it is called the 10’s complement.

Binary Subtraction using 1’s and 2’s Complement The 1’s complement of a binary number is simply obtained by replacing every 1 by 0 , and every 0 by 1. The 2’s complement of a binary number can be obtained in two ways: By adding 1 to the 1’s 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.

Ex 1: Obtain the two’s complement of the binary number 1011010.110 First solution Second solution

Ex 2: Calculate the following binary Subtraction: 11101. 101 – 1011 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

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 1’s complement of the result (if using 1’s complement initially), or the negative of 2’s complement of the result (if using 2’s complement initially).

Ex 2: Calculate the following binary Subtraction: 1101. 101 – 11011 then verify the result in decimal System. Solution Therefore, the result = - (the 1’s complement of 10001.110) = - 01110.001 Or = - ( the 2’s complement of 10001.111 ) = - 01110.001

Questions