Chapter 3 Complements Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.

Slides:



Advertisements
Similar presentations
EET 1131 Unit 7 Arithmetic Operations and Circuits
Advertisements

Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
ECE 331 – Digital System Design
King Fahd University of Petroleum and Minerals
CS 151 Digital Systems Design Lecture 3 More Number Systems.
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 )
Negative Numbers Module M3.3 Section 2.4. Negative Numbers Subtract by adding ’s complement Ignore carry.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Number Systems and Codes Discussion D4.1. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
Introduction to Computer Science
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
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:
Digital Systems and Binary Numbers
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
BINARY ARITHMETIC Binary arithmetic is essential in all digital computers and in many other types of digital systems.
Complement Numbers. Outline  Negative Numbers Representation  Sign-and-magnitude  1s Complement  2s Complement  Comparison of Sign-and-Magnitude.
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.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Summer 2012ETE Digital Electronics1 Binary Arithmetic of Signed Binary Numbers.
Positional Number Systems
Operations on Bits Arithmetic Operations Logic Operations
Exam1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Chapter 3 Complements Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
By Jariya Phongsai A two's-complement system is a system in which negative numbers are represented by the two's complement of the absolute value; this.
Combinational Circuits
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Introduction To Number Systems Binary System M. AL-Towaileb1.
IT1004: Data Representation and Organization Negative number representation.
CPEN Digital Logic Design Binary Systems Spring 2004 C. Gerousis © Digital Design 3 rd Ed., Mano Prentice Hall.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Exam1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
DIGITAL Logic DESIGN Digital system and binary numbers Lecturer: Ms. Farwah Ahmad.
Representing Positive and Negative Numbers
CPE 201 Digital Design Lecture 3: Digital Systems & Binary Numbers (3)
Negative Binary Numbers
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Digital Systems and Binary Numbers
Negative Binary Numbers
Chapter 3 Data Representation
Addition and Substraction
Binary Addition & Subtraction
Complement Theory 1’s and, 2’s complement operation
Number Representation
MMNSS COLLEGE,KOTTIYAM DEPARTMENT OF PHYSICS
COMPLEMENTS Complements are used in digital computers for simplifying the subtraction operations and for logical manipulation. There are two types of complements.
King Fahd University of Petroleum and Minerals
EE207: Digital Systems I, Semester I 2003/2004
Data Representation – Chapter 3
Unit 18: Computational Thinking
2’s Complement form 1’s complement form 2’s complement form
CPS120: Introduction to Computer Science
Instructor: Alexander Stoytchev
Binary to Decimal Conversion
ECE 331 – Digital System Design
CSC 220: Computer Organization Signed Number Representation
Negative Bit Representation Outline
Arithmetic Operation By: Asst Lec. Besma Nazar Nadhem
Chapter3 Fixed Point Representation
Chapter 1 (Part c) Digital Systems and Binary Numbers
Introduction To Number Systems
Today Binary addition Representing negative numbers 2.
Presentation transcript:

Chapter 3 Complements Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009

Subtraction using addition Conventional addition (using carry) is easily implemented in digital computers. However; subtraction by borrowing is difficult and inefficient for digital computers. Much more efficient to implement subtraction using ADDITION OF the COMPLEMENTS of numbers.

Complements of numbers (r-1 )’s Complement Given a number N in base r having n digits, the (r- 1)’s complement of N is defined as (r n - 1) - N For decimal numbers the base or r = 10 and r- 1= 9, so the 9’s complement of N is (10 n -1)-N 99999……. - N Digit n Digit n-1 Next digit First digit

2- Find the 9’s complement of and The 9’s complement of is = and the 9’s complement of is = ’s complement Examples

l’s complement For binary numbers, r = 2 and r — 1 = 1, r-1’s complement is the l’s complement. The l’s complement of N is (2n - 1) - N. Digit n Digit n-1 Next digit First digit Bit n-1Bit n-2…….Bit 1Bit 0 -

l’s complement Find r-1 complement for binary number N with four binary digits. r-1 complement for binary means 2-1 complement or 1’s complement. n = 4, we have 2 4 = (10000) 2 and = (1111) 2. The l’s complement of N is ( ) - N. = (1111) - N

The complement 1’s of is The 1’s complement of is l’s complement

r’s Complement Given a number N in base r having n digits, the r’s complement of N is defined as r n - N. For decimal numbers the base or r = 10, so the 10’s complement of N is 10 n -N ……. - N Digit n Digit n-1 Next digit First digit

10’s complement Examples Find the 10’s complement of and The 10’s complement of is = and the 10’s complement of is = Notice that it is the same as 9’s complement

For binary numbers, r = 2, r’s complement is the 2’s complement. The 2’s complement of N is 2 n - N. 2’s complement Digit n Digit n-1 Next digit First digit

2’s complement Example The 2’s complement of is The 2’s complement of is

Fast Methods for 2’s Complement Method 1: The 2’s complement of binary number is obtained by adding 1 to the l’s complement value. Example: 1’s complement of is (invert the 0’s and 1’s) 2’s complement of is =

Fast Methods for 2’s Complement Method 2: The 2’s complement can be formed by leaving all least significant 0’s and the first 1 unchanged, and then replacing l’s by 0’s and 0’s by l’s in all other higher significant bits. Example: The 2’s complement of is Leave the two low-order 0’s and the first 1 unchanged, and then replacing 1’s by 0’s and 0’s by 1’s in the four most significant bits.

Examples –Finding the 2’s complement of ( ) 2 Method 1 – Simply complement each bit and then add 1 to the result. ( ) 2 [N] = 2’s complement = 1’s complement ( ) 2 +1 =( ) 2 Method 2 – Starting with the least significant bit, copy all the bits up to and including the first 1 bit and then complement the remaining bits. N = [N] =

Subtraction of Unsigned Numbers using r’s complement Subtract N from M : M – N r’s complement N  (rn – N ) add M to ( rn – N ) : Sum = M + ( r n – N) take r’s complement (If M  N, the negative sign will produce an end carry  rn we need to take the r’s complement again.)

Subtraction of Unsigned Numbers using r’s complement (1) if M  N, ignore the carry without taking complement of sum. (2) if M < N, take the r’s complement of sum and place negative sign in front of sum. The answer is negative.

Example 1 (Decimal unsigned numbers), perform the subtraction = M > N : “Case 1” “Do not take complement of sum and discard carry” The 10’s complement of is Therefore: M = ’s complement of N = Sum= Discard end carry 10 5 = Answer = 59282no complement

Example 2; Now consider an example with M <N. The subtraction produces negative Using the procedure with complements, we have M = ’s complement of N = Sum = Take 10’s complement of Sum = The number is : Place negative sign in front of the number:-59282

Gray code هذه الشفرة تسمى " منعكسة " ( كما فى المرآة ) البدء بالرقمين صفر وواحد ثم عكسهما واحد وصفر وهكذا كما فى الجدول المرفق، وللإيضاح وضعت ألوان توضح صفر - واحد بالأصفر والعكس بلون آخر هذا فى خانة الآحاد.