CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739

Slides:



Advertisements
Similar presentations
Integers. Integer Storage Since Binary consists only of 0s and 1s, we can’t use a negative sign ( - ) for integers. Instead, the Most Significant Bit.
Advertisements

Addition of two binary numbers = = = = 39.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE116: Introduction to Computer Science 2 Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
King Fahd University of Petroleum and Minerals
Signed Numbers Up till now we've been concentrating on unsigned numbers. In real life we have to represent signed numbers ( like: -12, -45, 78). The difference.
Negative Numbers Module M3.3 Section 2.4. Negative Numbers Subtract by adding ’s complement Ignore carry.
Data Representation ICS 233
Exercise 2.5 If each number is represented with 5 bits, 7 = in all three systems -7 = (1's complement) = (signed magnitude) = (2's.
CSE20 Lecture 3 Number Systems: Negative Numbers 1.Sign and Magnitude Representation 2.1’s Complement Representation 3.2’s Complement Representation 1.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
3. Representing Integer Data
Binary Addition Addition Rules: = = = = = carry 1 1 carry 1 Example 1: Example 2:
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
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,
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall 1.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
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.
Number Representation
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
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.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Addition and Substraction
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
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=
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Negative Integer Representation.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
IT1004: Data Representation and Organization Negative number representation.
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.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
Representing Positive and Negative Numbers
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:
Backgrounder: Binary Math
Addition and Substraction
Unit 18: Computational Thinking
CPS120: Introduction to Computer Science
Decimal and binary representation systems
Presentation transcript:

CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:

Agenda Today: –Two’s complement representation

Two’s complement fixed-width encoding limited range of values encodes both negative and non-negative values familiar properties hold –unique representation of zero ( 0 = -0 ) –x = - ( -x ) –x + (-x) = 0 –x - y = x + ( -y ) last property lets us use addition circuitry to perform subtraction

Bit pattern interpretation half of bit patterns (those with a zero in the leftmost bit) are for non- negative values, and are interpreted just as base 2 (binary) numbers are the assignment of values to the remaining bit patterns is done as described on the following slides

-x To find representation of -x given the representation of x: 1.find the one’s complement of x do this by flipping all the bits in the representation (1 becomes 0, 0 becomes 1) 2.find the two’s complement of the result do this by adding one to the one’s complement, ignoring any overflow carry

Example Using a 4-bit wide representation, find the representation of -3: –representation: 0011 –one’s complement: 1100 –two’s complement: 1101 Representation of -3 is 1101 Exercise: verify that the desirable properties hold!

Extra pattern? since -0 = 0, there is one leftover “negative” bit string let that represent a negative number, -8 in the case of a 4-bit wide representation in general, range of values for a k-bit wide two’s complement representation is from -2 (k-1) to +2 (k-1) -1 for 4-bit wide representation: -8 to +7

Rollover What happens when you add 1 to 7 in the 4-bit wide scheme? = 1000 The answer is -8 (!) Adding one to the largest magnitude positive number yields the largest magnitude negative number.

Extra negative number The negative of the largest magnitude negative number is itself. In the 4-bit wide scheme, -(-8) is -8.

Understand the representation! It is important that you understand the limitations of working with fixed-width representations.