IT1004: Data Representation and Organization Negative number representation.

Slides:



Advertisements
Similar presentations
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:
Advertisements

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.
Addition of two binary numbers = = = = 39.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Assembly Language and Computer Architecture Using C++ and Java
Signed Numbers.
Assembly Language and Computer Architecture Using C++ and Java
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
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)
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Number System and Codes
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
School of Computer Science G51CSA 1 Computer Arithmetic.
3. Representing Integer Data
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Representation and Computer Arithmetic
Binary Addition Addition Rules: = = = = = carry 1 1 carry 1 Example 1: Example 2:
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
1 Week 3: Data Representation: Negative Numbers READING: Chapter 3.
Simple Data Type Representation and conversion of numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
Data Representation – Binary Numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
Representing Integer Data Book : Chapter ( Subject has no point !! ) A99ACF.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Computer Architecture
Complement Numbers. Outline  Negative Numbers Representation  Sign-and-magnitude  1s Complement  2s Complement  Comparison of Sign-and-Magnitude.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
9.4 FLOATING-POINT REPRESENTATION
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 20, 2004 Lecture Number: 23.
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.
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.
Summer 2012ETE Digital Electronics1 Binary Arithmetic of Signed Binary Numbers.
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
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,
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Addition and Substraction
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
ECE 3110: Introduction to Digital Systems Number Systems: signed numbers.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
{ Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
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.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
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:
Department of Computer Science Georgia State University
Addition and Subtraction
ECE 2110: Introduction to Digital Systems
Data Representation Data Types Complements Fixed Point Representation
Data Representation – Chapter 3
Unit 18: Computational Thinking
CPS120: Introduction to Computer Science
Chapter3 Fixed Point Representation
Presentation transcript:

IT1004: Data Representation and Organization Negative number representation

Sign-Magnitude Representation This is one method used to represent negative numbers in Binary Here an extra digit is placed in front the existing binary number to represent the sign If this extra digit is a '1', it means that the rest of the digits represent a negative number If the extra digit is a 0', it means that the number is a positive Example : +37 = (in 8 bits) -37 = (in 8 bits) 2 What is the range of numbers that can be represented in this method?

Sign-Magnitude Representation… Example 2: +127 = (in 8 bits) = (in 8 bits) Example 3 : 0= (in 8 bits) if we consider negative value of this bit stream we get This is also representing zero This is a drawback of Sign-Magnitude representation (That is two values to represent zero as +0 and -0) 3

One’s complement One's complement number representation is used for signed numbers in binary format To obtain the 1's complement of a number: – Get the binary format of the given number – Complement all the bits in the binary number there are different representations for +0 and -0 in one's complement. Examples of 8-bit one's complement numbers: BIT PatternDecimal ValueBIT PatternDecimal Value

One’s complement The range of 8-bit one's complement integers is -127 to Exercises: Find the 1’s complement of ABC

Addition in One’s complement Addition of signed numbers in one's complement is performed using binary addition with end-around carry. If there is a carry out of the most significant bit of the sum, this bit must be added to the least significant bit of the sum. To add decimal 17 to decimal -8 in 8-bit one's complement: (17) (-8 ) = ( 9 ) 8 10 =

Two’s complement number representation

Two’s complement Two's complement number representation is used for signed numbers on most modern computers. This notation allows a computer to add and subtract numbers using the same operations We can illustrate two's complement notation as follows: – A fixed number of bits are used to represent numbers – The most significant bit is called the sign bit – This same notation is used to represent both positive and negative numbers

Two’s complement… Positive numbers are represented normally Example 1: Using a 4 bit representation 5 in 2's complement = 0101 Example 2: Using an 8 bit representation 5 in 2's complement = Example 3: Using an 8 bit representation 24 base 16=

Two’s complement… To obtain the 2's complement of a number: – Complement the bits – Add one to the result Negative numbers Are represented using a 2's complement form Example1 : Find the 2’s complement of the following 8 bit number …………..First, invert the bits …………..Then, add 1 = The 2’s complement of is

Two’s complement… Example 3: (4 bits) Represent -3 in 2's complement +3 ……………………0011 complement …….1100 add 1 ……………… = 1101 Example 2 : (4 bits) Represent -6 in 2's complement +6 ……………………0110 complement …….1001 add 1 ……………… = 1010 Example 4: (5 bits) Represent -13 in 2's complement +13 ………………… complement … add 1 …………… = 10011

Two’s complement… Represent the following numbers in two’s complement form using 5 bits Represent the following numbers in two’s complement form using 8 bits

Addition and subtraction in 2's complement notation Addition is performed by doing the simple binary addition of the two numbers. Subtraction is accomplished by first performing the 2's complement operation on the number being subtracted and then adding the two numbers …… …… …… …… ……… ……… Examples: 5 bits 8 ……… ……… ………

Addition and subtraction in 2's complement notation Since we are working with numbers contained in a fixed number of bits, we must be able to detect overflow following an operation. No overflow occurs when the value of the bit carried into the most significant bit is the same as the value carried out of the most significant bit. Overflow occurs when the value of the bit carried into the most significant bit is not the same as the bit carried out of the most significant bit. 14

Addition and subtraction in 2's complement notation Example: 4 bits 15 6 ……… ……… ……… ……… ……… 1000 X This means a negative number Here we can get the correct answer by increasing the number of bits

Addition and subtraction in 2's complement notation Example: 5 bits 16 6 ……… ……… ……… ……… ……… √

Addition and subtraction in 2's complement notation… Perform the following calculations in two’s complement method using 5 bits Perform the following calculations in two’s complement method using 8 bits

Polynomial Evaluation Whole Numbers (Radix = 10): = 1     10 0 With Fractional Part (Radix = 10): = 3     General Case (Radix = R): (S 1 S 0.S -1 S -2 ) R = S 1  R 1 + S 0  R 0 + S -1  R -1 + S -2  R -2