NEGATIVE BINARY NUMBER 350151 – Digital Circuit 1 Choopan Rattanapoka.

Slides:



Advertisements
Similar presentations
Representing Numbers: Integers
Advertisements

COE 202: Digital Logic Design Signed Numbers
Radix Conversion Given a value X represented in source system with radix  s, represent the same number in a destination system with radix  d Consider.
ECE 331 – Digital System Design
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Number Systems Standard positional representation of numbers:
Sistemas Digitais I LESI - 2º ano Lesson 2 - Number Systems U NIVERSIDADE DO M INHO E SCOLA DE E NGENHARIA Prof. João Miguel Fernandes
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
ECE 331 – Digital System Design
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
CSE20 Lecture 3 Number Systems: Negative Numbers 1.Sign and Magnitude Representation 2.1’s Complement Representation 3.2’s Complement Representation 1.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Introduction to Number Systems
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
Number Systems Computer Science 210 Computer Organization.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
Binary Representation and Computer Arithmetic
Representing Integer Data Book : Chapter ( Subject has no point !! ) A99ACF.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Dale & Lewis Chapter 3 Data Representation. Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video,
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Complement Numbers. Outline  Negative Numbers Representation  Sign-and-magnitude  1s Complement  2s Complement  Comparison of Sign-and-Magnitude.
Number Systems. Why binary numbers? Digital systems process information in binary form. That is using 0s and 1s (LOW and HIGH, 0v and 5v). Digital designer.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
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. Today Decimal Hexadecimal Binary –Unsigned Binary –1’s Complement Binary –2’s Complement Binary.
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.
– Digital Circuit 1 Choopan Rattanapoka
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Positional Number Systems
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
Topic 1 – Number Systems. What is a Number System? A number system consists of an ordered set of symbols (digits) with relations defined for addition,
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Logic and Computer Design.
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Sep 29, 2004Subtraction (lvk)1 Negative Numbers and Subtraction The adders we designed can add only non-negative numbers – If we can represent negative.
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.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
1 Understand the examples again Overflow –When two positive numbers added together or a negative number subtracted from a positive number yields negative.
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=
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
Introduction * Binary numbers are represented with a separate sign bit along with the magnitude. * For example, in an 8-bit binary number, the MSB is.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
IT1004: Data Representation and Organization Negative number representation.
Two’s and one’s complement arithmetic CLOCK ARITHMETIC.
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.
Numerical formats What’s the main idea? Want to represent numbers (eg: 45, -12, ) using only bits. We’ve already seen (or you can read in the book)
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Representing Positive and Negative Numbers
Cosc 2150: Computer Organization
Addition and Subtraction
CSE 102 Introduction to Computer Engineering
Computer Organization and ASSEMBLY LANGUAGE
Presentation transcript:

NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka

Representing Negative Numbers in Binary  Up to this point, we have not been discussed how to represent negative numbers in binary.  Ex: 5 10 – 7 10 = How to represent in binary ?  There are several representation :  Signed-magnitude representation.  2’s complement representation (radix complement)  1’s complement representation (reduced radix complement)

Signed-Magnitude  It’s the simplest representation for negative binary numbers.  In most computers, in order to represent both positive and negative numbers. The first bit is used as a sign bit.  0 used for plus.  1 used for minus.  Thus, for n-bit word, the first bit is the sign bit and n-1 bits represent the magnitude of the number Sign bit Magnitude

Example  Use signed-magnitude representation to represent these negative decimal numbers (8-bits)  -50  50  50/2 = 25 remainder 0 25/2 = 12 remainder 1 12/2 = 6 remainder 0 6/2 = 3 remainder 0 3/2 = 1 remainder 1  50   ( add 0 to make magnitude 8 bits)  -50  (add sign bit [1 for negative])

Exercise 1  Transform these decimal numbers to signed- magnitude representation.  4 bits  8 bits -100  16 bits -256

1’s Complement (1)  The 1’s complement of an N-digits binary integer B: 1’s complement = (2 N – 1) – B Example : Convert to 4-bit 1’s complement 1’s complement = (2 4 – 1) – 5 = (16 – 1) – 5 =  =

1’s Complement (2)  Example : Convert -120 to a 8-bit 1’s complement representation 1’s complement = (2 8 – 1) – 120 = 256 – 1 – 120 =   Let’s look again to simplify 1’s complement representation. For 4-bits For 8-bits 5    

Exercise 2  Transform these decimal numbers to 1’s complement representation.  4 bits  8 bits -100  16 bits -256

2’s Complement (1)  Generating 2’s complement is more complex than other representations.  However, 2’s complement arithmetic is simpler than other arithmetic.  2’s complement = 2 N – B, B ≠ 0 0, B = 0

2’s Complement (2) Example 1: Convert to 4-bit 2’s complement 2’s complement = 2 4 – 5 = 16 – 5 =  = Example 2: Convert to 8-bit 2’s complement representation 2’s complement = 2 8 – 120 = 256 – 120 = 136  =

2’s Complement (3)  Another method to calculate 2’s complement  Convert number to 1’s complement  Then, add 1 to that number  Example : Convert to 8-bit 2’s complement representation = ’s complement  (invert bits) 2’s complement  = =

2’s Complement (4)  Another method to calculate 2’s complement  Keep same bit from LSB  MSB until found “1”  Do 1’s complement on the rest bits.  Example : Convert to 8-bit 2’s complement representation = =

Exercise 3  Transform these decimal numbers to 2’s complement representation.  4 bits  8 bits -100  16 bits -256

Exercise 4  Find the equivalent decimal number of when these negative binary numbers are represented by signed-magnitude, 1’s complement, and 2’s complement (8-bit).    

4 bit Microprocessor + NPositive Integers (all systems) - NSign and Magnitude 2’s Complement N * 1’s Complement N

Recall binary subtraction    –  Binary subtraction is not easy to implement in digital circuit.  Thus, we try to implement the binary addition of negative value instead.

1’s Complement Subtraction  – 5 10  (– 5 10 )   ( )  11 10

2’s Complement Subtraction  – 5 10  (– 5 10 )   ( )   Faster and easier than signed-magnitude and 1’s complement subtraction.

Overflow and Underflow  Overflow occurs when an arithmetic operation yields a result that is greater than the range’s positive limit of 2 N-1 – 1  Underflow occurs when an arithmetic operation yields a result that is less than the range’s negative limit of -2 N-1

Example : overflow  (4-bits 2’s complement)  Note that 4 bits can store +7 to  ≠ -5 OVERFLOW

Example : underflow  (4-bits 2’s complement)  Note that 4 bits can store +7 to  ≠ 4 UNDERFLOW

Exercise 5 (TODO)  Transform these decimal number to negative binary signed- magnitude, 1’s complement, 2’s complement representation (8-bits)  -10, -98, -142, -200, -215  Find the result of these decimal arithmetic in negative binary signed-magnitude, 1’s complement, 2’s complement representation (8-bits)   200 – 50  215 – 98  -25 – 9  -200 – 215