Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.

Slides:



Advertisements
Similar presentations
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Advertisements

Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
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.
EMB1006 The Binary System There is no 2 Jonathan-Lee Jones.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
J. Michael Moore Computer Organization CSCE 110. J. Michael Moore High Level View Of A Computer ProcessorInputOutput Memory Storage.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
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.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Mathematics with Binary. Question  Below is a binary string  Which is the least significant bit (LSB)?  Which is the most significant bit (MSB)? 0.
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.
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.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Two’s Complement 1.As an action: (Assume the starting value is 1011) 1.Flip the bits from the starting value => Add one to get the answer.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
3. Representing Integer Data
Rules of Integers. Positive numbers are numbers that are above zero. Negative numbers are numbers below zero.
1 Week 3: Data Representation: Negative Numbers READING: Chapter 3.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
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,
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 29, 2004 Lecture Number: 26.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
+ CS 325: CS Hardware and Software Organization and Architecture Integers and Arithmetic Part 2.
When we add or subtract integers we can use a number line to help us see what is happening with the 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.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.
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.
Operations on Bits Arithmetic Operations Logic Operations
Integers Lesson 1a: Integers Integers are whole numbers and their opposites. Negative integers are numbers less than zero. Positive integers are numbers.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Chapter 3 Complements Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
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.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
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.
Adding, Subtracting, Multiplying, and Diving Integers!!!
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
Lecture 6 Excess Notation. Excess 8 notation indicates that the value for zero is the bit pattern for 8, that is 1000 Excess 8 notation indicates that.
IT1004: Data Representation and Organization Negative number representation.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
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.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
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 Patterson and Hennessy Text.
Computer Engineering page 1 Integer arithmetic Depends what you mean by “integer”. Assume at 3-bit string. –Then we define: zero = 000 one = 001 Use zero,
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Unit 18: Computational Thinking
Presentation transcript:

Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text

Review Previously we briefly looked at binary addition and subtraction. For this lecture we will consider 4-bit binary numbers since they are easy to write on the board.

Signed Integer If we wish to represent signed integers, a straightforward way to represent them on a computer is to use one bit for the sign (0 for positive and 1 for negative) and allow the remaining three bits to represent the value. Using four bits we have 16 possible values. Positive numbers follow below. Notice that the first bit is zero, indicating that these are positive integers. 0000b = 0d 0001b = 1d 0010b = 2d 0011b = 3d 0100b = 4d 0101b = 5d 0110b = 6d 0111b = 7d 1000b = -0d 1001b = -1d 1010b = -2d 1011b = -3d 1100b = -4d 1101b = -5d 1110b = -6d 1111b = -7d Negative numbers: Notice that we have a negative zero.

Addition Let's investigate addition with these values. Addition with positive integers works: 0011b = 3d +0100b = 4d b = 7d But what about addition of positive and negative integers? Notice that this is the same as subtraction. 0010b = 2d +1101b = -5d b != -3d

Addition Contd. It is going to take lots of effort to compute the difference between two numbers. We need a different representation to perform such an addition. Let's look at one's complement representation of binary numbers. In one's complement, positive binary numbers are represented as above including the sign bit. To represent negative binary numbers in one's complement, we simply perform a bit flip. Let's examine how this works: 0000b = 0d1111 = -0d (this might be a problem) 0001b = 1d1110 = -1d 0010b = 2d1101 = -2d 0011b = 3d1100 = -3d 0100b = 4d1011 = -4d 0101b = 5d1010 = -5d 0110b = 6d1001 = -6d 0111b = 7d1000 = -7d

2’s Compliment Let's see if we can perform binary additions between positive and negative numbers as follows: 1101b = -2d +0101b = 5d b != 3d Notice that we are off by one from our correct answer. Let's try modifying our representation. Two's complement binary numbers are slightly different from one's complement numbers. To find the value of our negative numbers, we perform a bit flip and add one.

2’s Compliment 0000b = 0d 0001b = 1d 1111 = -1d 0010b = 2d 1110 = -2d 0011b = 3d 1101 = -3d 0100b = 4d 1100 = -4d 0101b = 5d 1011 = -5d 0110b = 6d 1010 = -6d 0111b = 7d 1001 = -7d 1000 = -8d Notice that we could represent 1000 as 8, but it might be better to represent it as -8. Why? Notice that if we perform binary additions between positive and negative numbers, they now work.

2’s Compliment 1110b = -2d +0101b = 5d b = 3d Additionally, notice that if we add numbers that should sum to zero, it works as well: 1101b = -3d +0011b = 3d b = 0d Next time we will look at binary representations for floating point numbers.