ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.

Slides:



Advertisements
Similar presentations
Lecture no 6. Two's Complement Given a negative number (N), represented using the Two's Complement representation (N*), the magnitude of the number (P)
Advertisements

HEXADECIMAL NUMBERS Code
Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
ELEC353 S. al Zahir UBC Sign-Magnitude Representation High order bit is sign: 0 = positive (or zero), 1 = negative Low order bits represent the magnitude:
Computer Engineering (Logic Circuits) Dr. Tamer Samy Gaafar Lec. # 2
ECE 331 – Digital System Design
ECE 331 – Digital System Design
King Fahd University of Petroleum and Minerals
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
ECE 331 – Digital System Design
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.
ECE 301 – Digital Electronics
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Number Systems and Codes Discussion D4.1. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
1.6 Signed Binary Numbers.
Dr. Bernard Chen Ph.D. University of Central Arkansas
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Digital Systems and Logic Design
BINARY ARITHMETIC Binary arithmetic is essential in all digital computers and in many other types of digital systems.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Yuh-Jzer JoungDigital Systems1 Number Systems decimal number : 7397=7× × × ×10 0 a 4 a 3 a 2 a 1 a 0. a -1 a -2 = a 4 ×10 4 +a 3 ×10.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
1 Digital Design: Number Systems Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals of Logic.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
ECE 331 – Digital System Design
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
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.
ECE 2110: Introduction to Digital Systems BCD, Gray, Character, Action/Event, Serial Data.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
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.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Combinational Circuits
1 Positive numbers are well understood An n-bit number represents numbers from 0 to 2 n -1 n+m bits can be used to represent n-bit integer and m-bit fraction.
Ahmad Almulhem, KFUPM 2009 COE 202: Digital Logic Design Number Systems Part 4 Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:
CEC 220 Digital Circuit Design Binary Codes
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
MECH1500 Chapter 3.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
CCE Department – Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic.
Introduction to Digital Electronics Lecture 2: Number Systems.
CEC 220 Digital Circuit Design Binary Codes Mon, Aug 31 CEC 220 Digital Circuit Design Slide 1 of 14.
CSC 331: DIGITAL LOGIC DESIGN COURSE LECTURER: E. Y. BAAGYERE. CONTACT: LECTURE TIME: 15:40 – 17:45 hrs. VENUE: SP-LAB.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
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 Math CPS120 Introduction to Computer Science Lecture 7.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Lecture 4: Digital Systems & Binary Numbers (4)
Unit I From Fundamentals of Logic Design by Roth and Kinney.
Negative Number Sign-Magnitude: left-most bit as the sign bit –16 bits –Example: 4-bit numbers is given by is given by ’s complement:
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication,
Unit 18: Computational Thinking
ECE 331 – Digital System Design
Lecture No.5.
Presentation transcript:

ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included herein were taken from the materials accompanying Fundamentals of Logic Design, 6 th Edition, by Roth and Kinney, and were used with permission from Cengage Learning.

Spring 2011ECE Digital Electronics2 Representation of Negative Numbers (continued)

Spring 2011ECE Digital Electronics3 Signed Binary Numbers Representations for signed binary numbers: 1. Sign and Magnitude 2. 1's Complement 3. 2's Complement

Spring 2011ECE Digital Electronics4 Signed Binary Numbers Arithmetic circuits are difficult to design for Sign and Magnitude binary numbers. Consequently, this number system is not typically used in digital (computer) systems. Instead other number systems, namely the 1's and 2's Complements, are more commonly used. As we will see, it is rather easy to design arithmetic circuits for binary numbers represented in these number systems.

Spring 2011ECE Digital Electronics5 1's Complement A positive number, N, is represented in the same way as in the Sign and Magnitude representation. For an n-bit number,  The leftmost bit (sign bit) = 0. Indicating a positive number.  The remaining n-1 bits represent the magnitude.

Spring 2011ECE Digital Electronics6 1's Complement A negative number, -N, is represented by the “1's complement” of the positive number, N. N' = 1's complement representation for -N. For an n-bit signed binary number,  The leftmost bit (sign bit) = 1 for all negative numbers in the 1's Complement system. N' = (2 n – 1) – N

Spring 2011ECE Digital Electronics7 1's Complement: Examples Using 8 bits, determine the 1's Complement representation for the following negative numbers:

Spring 2011ECE Digital Electronics8 1's Complement The 1's Complement representation for -N can also be determined by taking the bit-wise complement of N. N' = 1's Complement representation for -N. For an n-bit signed binary number,  i.e. complement N, bit-by-bit N' = bit-wise complement of N

Spring 2011ECE Digital Electronics9 1's Complement: Examples Using 8 bits, determine the 1's Complement representation for the following negative numbers: (Use the bit-wise complement)

Spring 2011ECE Digital Electronics10 1's Complement For an n-bit 1's Complement binary number,  Includes a representation for +0 and -0.  Represents an equal number of positive and negative values. - (2 n-1 – 1) <= N <= + (2 n-1 – 1)

Spring 2011ECE Digital Electronics11 1's Complement To determine the magnitude of a negative number, -N, that is represented by its 1's Complement, N', simply take the “1's complement” of the 1's Complement. N = (2 n – 1) – N' N = bit-wise complement of N' or positive # 1's complement rep. for negative #

Spring 2011ECE Digital Electronics12 2's Complement A positive number, N, is represented in the same way as in the Sign and Magnitude representation. For an n-bit number,  The leftmost bit (sign bit) = 0. Indicating a positive number.  The remaining n-1 bits represent the magnitude.

Spring 2011ECE Digital Electronics13 2's Complement A negative number, -N, is represented by the “2's complement” of the positive number, N. N* = 2's complement representation for -N. For an n-bit signed binary number,  The leftmost bit (sign bit) = 1 for all negative numbers in the 2's Complement system. N* = (2 n ) – N

Spring 2011ECE Digital Electronics14 2's Complement: Examples Using 8 bits, determine the 2's Complement representation for the following negative numbers:

Spring 2011ECE Digital Electronics15 2's Complement The 1's and 2's Complement representations for a negative number, -N, are related as follows: N* = (2 n ) – N N' = (2 n - 1) – N N* = N' +1

Spring 2011ECE Digital Electronics16 2's Complement Thus, the 2's Complement representation for - N can also be determined by adding 1 to the 1's Complement representation for -N.  N' = 1's Complement representation for -N.  N* = 2's Complement representation for -N. For an n-bit signed binary number, N* = N' + 1

Spring 2011ECE Digital Electronics17 2's Complement: Examples Using 8 bits, determine the 2's Complement representation for the following negative numbers: (Use the 1's complement)

Spring 2011ECE Digital Electronics18 2's Complement For an n-bit 2's Complement binary number,  Includes only one representation for 0.  Represents an additional negative value. - (2 n-1 ) <= N <= + (2 n-1 – 1)

Spring 2011ECE Digital Electronics19 2's Complement To determine the magnitude of a negative number, -N, that is represented by its 2's Complement, N*, simply take the “2's complement” of the 2's Complement. N = (2 n ) – N* N = (N*)' + 1 or positive # 2's complement rep. for negative # bit-wise complement of 2's complement

Spring 2011ECE Digital Electronics20 Signed Binary Numbers

Spring 2011ECE Digital Electronics21 Binary Arithmetic of Signed Binary Numbers

Spring 2011ECE Digital Electronics22 2's Complement Addition Addition of n-bit signed binary numbers is straightforward using the 2's Complement number system. Addition is carried out in the same way as for n-bit positive numbers. Carry from the sign bit (leftmost bit) is ignored. Overflow occurs if the correct result (including the sign bit) cannot be represented in n bits.

Spring 2011ECE Digital Electronics23 2's Complement Addition: Example Using 2's Complement addition and 8-bit representation, add the following numbers: Did overflow occur?

Spring 2011ECE Digital Electronics24 2's Complement Addition: Example Using 2's Complement addition and 8-bit representation, add the following numbers: Did overflow occur?

Spring 2011ECE Digital Electronics25 2's Complement Addition: Example Using 2's Complement addition and 8-bit representation, add the following numbers: Did overflow occur?

Spring 2011ECE Digital Electronics26 2's Complement Addition: Example Using 2's Complement addition and 8-bit representation, add the following numbers: Did overflow occur?

Spring 2011ECE Digital Electronics27 2's Complement Subtraction Subtraction can be implemented using addition.  Determine the 2's Complement representation for the negative number -B.  Use 2's Complement addition to add A and -B. A – B = A + (-B)

Spring 2011ECE Digital Electronics28 2's Complement Subtraction: Example Subtract the following numbers, using 2's Complement addition and 8-bit representation: 64 – 78 Did overflow occur?

Spring 2011ECE Digital Electronics29 2's Complement Subtraction: Example Subtract the following numbers, using 2's Complement addition and 8-bit representation: -35 – 62 Did overflow occur?

Spring 2011ECE Digital Electronics30 2's Complement Subtraction: Example Subtract the following numbers, using 2's Complement addition and 8-bit representation: 14 – (-59) Did overflow occur?

Spring 2011ECE Digital Electronics31 2's Complement Subtraction: Example Subtract the following numbers, using binary subtraction and 8-bit representation: 27 – 45 Can this subtraction be carried out?

Spring 2011ECE Digital Electronics32 1's Complement Addition Similar to 2's Complement Addition of n-bit signed binary numbers. However, rather than ignore the carry-out from the sign (leftmost) bit, add it to the least significant bit (LSB) of the n-bit sum.  Known as the end-around carry.

Spring 2011ECE Digital Electronics33 1's Complement Addition: Example Using 1's Complement addition and 8-bit representation, add the following numbers: Did overflow occur?

Spring 2011ECE Digital Electronics34 1's Complement Addition: Example Using 1's Complement addition and 8-bit representation, add the following numbers: Did overflow occur?

Spring 2011ECE Digital Electronics35 Overflow The general rule for detecting overflow when performing 2's Complement or 1's Complement Addition:  An overflow occurs when the addition of two positive numbers results in a negative number.  An overflow occurs when the addition of two negative numbers results in a positive number.  Overflow cannot occur when adding a positive number to a negative number.

Spring 2011ECE Digital Electronics36 Binary Codes

Spring 2011ECE Digital Electronics37 Binary Codes Weighted Codes  Each position in the code has a specific weight  Decimal value of code can be determined Unweighted Codes  Positions of code do not have a specific weight  Decimal value assigned to each code

Spring 2011ECE Digital Electronics38 Binary Codes n-bit Weighted Codes  Code:a n-1 a n-2 a n-3...a 1 a 0  Weights:w n-1, w n-2, w n-3,..., w 1, w 0  Decimal Value:a n-1 x w n-1 + a n-2 x w n-2 + … + a 1 x w 1 + a 0 x w 0 4-bit Weighted Code  Code:a 3 a 2 a 1 a 0

Spring 2011ECE Digital Electronics39 Binary Codes Examples of 4-bit weighted codes  bits → 16 code words Only 10 code words required to represent decimal digits  bits → 16 code words  Excess-3 (obtained from ) 4 bits → 16 code words

Spring 2011ECE Digital Electronics40 Binary Codes Examples of unweighted codes  2-out-of-5 Code Exactly 2 of the 5 bits are “1” for a valid code word. 10 valid code words.  Gray Code Code values for successive decimal digits differ in exactly one bit. 4 bits → 16 code words.

Spring 2011ECE Digital Electronics41 Binary Codes

Spring 2011ECE Digital Electronics42 Binary Coded Decimal (BCD) 4-bit binary number used to represent each decimal digit. Weighted code: Binary values 0000 … 1001 used to represent decimal values 0 … 9. Binary values 1010 … 1111 not used. Very different from binary representation.

Spring 2011ECE Digital Electronics43 Binary Coded Decimal In BCD, each decimal digit is replaced by its binary equivalent value. Example: Binary: =

Spring 2011ECE Digital Electronics44 ASCII American Standard Code for Information Interchange Common code for the storage and transfer of alphanumeric characters. 7-bit Weighted Code  Can represent 128 characters Used to represent letters, numbers, and other characters Any word or number can be represented using its ASCII code.

Spring 2011ECE Digital Electronics45 ASCII Code (incomplete)

Spring 2011ECE Digital Electronics46 Questions?