ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.

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

Lecture 7. Binary Codes Gray Code(s)  Unweighted code  Code values for successive decimal digits differ in exactly one bit.  Example: 2-bit Gray Code.
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
CHAPTER 2 Number Systems, Operations, and Codes
ECE 331 – Digital System Design
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.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
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.
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
Data Storage. SIGN AND MAGNITUDE Storing and representing numbers.
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.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Digital Systems and Logic Design
Binary Arithmetic & Data representation
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 2 Number.
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.
ECE 3110: Introduction to Digital Systems BCD, Gray, Character, Action/Event, Serial Data.
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.
1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
THE BINARY SYSTEM.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
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:
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
IT1004: Data Representation and Organization Negative number representation.
CCE Department – Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic.
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic Herbert G. Mayer, PSU Status 1/14/2016 Copied with Permission from prof. Mark PSU ECE.
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 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
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.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
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)
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:
ECE 2110: Introduction to Digital Systems
ECE 331 – Digital System Design
Lecture No.5.
Chapter 1 (Part c) Digital Systems and Binary Numbers
Presentation transcript:

ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) 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.

Fall 2010ECE Digital System Design2 Representation of Negative Numbers (continued)

Fall 2010ECE Digital System Design3 Signed Binary Numbers Three representations for signed binary numbers: 1. Sign and Magnitude 2. 1's Complement 3. 2's Complement

Fall 2010ECE Digital System Design4 1's Complement An n-bit positive number (P) is represented in the same way as in the Sign and Magnitude representation.  The sign bit (MSB) = 0.  The remaining n-1 bits represent the magnitude.

Fall 2010ECE Digital System Design5 1's Complement An n-bit negative number (N) is represented using the “1's Complement” of the equivalent positive number (P).  N' = 1's Complement representation for the negative number N.  N' = (2 n – 1) – P where P = |N|  The sign bit (MSB) = 1 for all negative numbers using the 1's Complement representation.

Fall 2010ECE Digital System Design6 1's Complement Example: Determine the 1's Complement representation for the following negative numbers, using 8 bits: Hint: (2 n – 1) = (2 8 – 1) = 255

Fall 2010ECE Digital System Design7 1's Complement The 1's Complement representation of N can also be determined using the bit-wise complement of P.  N = n-bit negative number  P = |N|  N' = 1's Complement representation of N.  N' = bit-wise complement of P i.e. complement P, bit-by-bit.

Fall 2010ECE Digital System Design8 1's Complement Example: Determine the 1's Complement representation (using the bit-wise complement) for the following negative numbers, using 8 bits:

Fall 2010ECE Digital System Design9 1's Complement For an n-bit signed binary number, - (2 n-1 – 1) <= D <= + (2 n-1 – 1) Includes a representation for -0 and +0. Represents an equal number of positive and negative values.

Fall 2010ECE Digital System Design10 1's Complement Given a negative number (N), represented using the 1's Complement representation (N'), the magnitude of the number (P) can be determined as follows: P = (2 n – 1) – N' or P = bit-wise complement of N'

Fall 2010ECE Digital System Design11 2's Complement An n-bit positive number (P) is represented in the same way as in the Sign and Magnitude representation.  The sign bit (MSB) = 0.  The remaining n-1 bits represent the magnitude.

Fall 2010ECE Digital System Design12 2's Complement An n-bit negative number (N) is represented using the “2's Complement” of the equivalent positive number (P).  N* = 2's Complement representation for the negative number N.  N* = (2 n ) – P where P = |N|  The sign bit (MSB) = 1 for all negative numbers using the 2's Complement representation.

Fall 2010ECE Digital System Design13 2's Complement Example: Determine the 2's Complement representation for the following negative numbers, using 8 bits: Hint: (2 n ) = (2 8 ) = 256

Fall 2010ECE Digital System Design14 2's Complement The 2's Complement representation is related to the 1's Complement representation as follows: N' = (2 n – 1) – P N* = (2 n ) – P N* = N' + 1

Fall 2010ECE Digital System Design15 2's Complement The 2's Complement representation of N can also be determined by adding 1 to the 1's Complement representation of N.  N = n-bit negative number  P = |N|  N' = One's Complement representation of N. N' = bit-wise complement of P.  N* = N' + 1

Fall 2010ECE Digital System Design16 2's Complement Example: Determine the 2's Complement representation (using the 1's Complement) for the following negative numbers, using 8 bits:

Fall 2010ECE Digital System Design17 2's Complement For an n-bit signed binary number, - (2 n-1 ) <= D <= + (2 n-1 – 1) Includes only one representation for 0. Represents an additional negative value.

Fall 2010ECE Digital System Design18 2's Complement Given a negative number (N), represented using the 2's Complement representation (N*), the magnitude of the number (P) can be determined as follows: P = (2 n ) – N* or P = bit-wise complement of N* + 1

Fall 2010ECE Digital System Design19 Signed Binary Numbers

Fall 2010ECE Digital System Design20 Binary Arithmetic of Signed Binary Numbers

Fall 2010ECE Digital System Design21 2's Complement Addition Addition of n-bit signed binary numbers is straightforward using the 2's Complement system. Addition is carried out in the same way as the addition of n-bit positive numbers. Carry from the sign position (MSB) is ignored. Overflow occurs if the correct result (including the sign) cannot be represented in n bits.

Fall 2010ECE Digital System Design22 2's Complement Addition Example:

Fall 2010ECE Digital System Design23 2's Complement Addition Example:

Fall 2010ECE Digital System Design24 2's Complement Addition Example:

Fall 2010ECE Digital System Design25 2's Complement Addition Exercise: Add the following numbers using 2's Complement Addition: Does overflow occur for either addition?

Fall 2010ECE Digital System Design26 Two'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)

Fall 2010ECE Digital System Design27 2's Complement Subtraction Exercise: Subtract the following numbers using 2's Complement Addition: 32 – – 63 Does overflow occur for either subtraction?

Fall 2010ECE Digital System Design28 1's Complement Addition Similar to the addition of n-bit numbers using 2's Complement Addition. Instead of discarding the carry from the sign position (MSB), it must be added to the least significant bit (LSB) of the n-bit sum.  Referred to as an end-around carry.

Fall 2010ECE Digital System Design29 1's Complement Addition Example:

Fall 2010ECE Digital System Design30 1's Complement Addition Example:

Fall 2010ECE Digital System Design31 1's Complement Addition Exercise: Add the following numbers using 1's Complement Addition: Does overflow occur for either addition?

Fall 2010ECE Digital System Design32 Overflow General rule for detecting overflow when adding two n-bit numbers using either 1's Complement or 2's Complement Addition  An overflow occurs when the addition of two positive numbers results in a negative value or the addition of two negative numbers results in a positive value.  Cannot occur when adding a positive number and a negative number.

Fall 2010ECE Digital System Design33 Binary Codes

Fall 2010ECE Digital System Design34 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

Fall 2010ECE Digital System Design35 Binary Codes 4-bit Weighted Codes  Code:a 3 a 2 a 1 a 0  Weights:w 3, w 2, w 1, w 0  Decimal Value:a 3 x w 3 + a 2 x w 2 + a 1 x w 1 + a 0 x w 0 Examples    Excess-3 (obtained from )

Fall 2010ECE Digital System Design36 Binary Codes Examples of unweighted codes  2-out-of-5 Code Exactly 2 of the 5 bits are “1” for a valid code word.  Gray Code Code values for successive decimal digits differ in exactly one bit.

Fall 2010ECE Digital System Design37 Binary Codes

Fall 2010ECE Digital System Design38 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.

Fall 2010ECE Digital System Design39 In the simplest form of binary code, each decimal digit is replaced by its binary equivalent. For example, is represented by: Binary Coded Decimal

Fall 2010ECE Digital System Design40 Binary Codes ASCII Code  American Standard Code for Information Interchange  Common code used for the storage and transfer of alphanumeric characters.  7-bit Weighted Code Can represent a total of 128 characters  Used to represent letters, numbers and other characters (e.g. special control characters)  Any word or number can be represented (and stored or transferred) using its ASCII Code.

Fall 2010ECE Digital System Design41 ASCII Code (incomplete)

Fall 2010ECE Digital System Design42 Questions?