Integers’ Representation. Binary Addition. Two's Complement. Unsigned number representation Binary Addition, Subtraction. Overflow of unsigned numbers.

Slides:



Advertisements
Similar presentations
HEXADECIMAL NUMBERS Code
Advertisements

Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
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:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
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.
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Operations on data CHAPTER 4.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
Arithmetic for Computers
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Binary Arithmetic & Data representation
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
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.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Number Representation
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.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
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.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
CPS3340 Computer Architecture Fall Semester, 2013
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
Introduction To Number Systems Binary System M. AL-Towaileb1.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
Arithmetic Operations
CDA 3101 Spring 2016 Introduction to Computer Organization
Integer Multiplication, Division Arithmetic shift Twice the number of places MIPS multiply unit. mult, multu Significant bits Mfhi, mflo, div, divu 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.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
Integer Operations Computer Organization and Assembly Language: Module 5.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
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 Math CPS120 Introduction to Computer Science Lecture 7.
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.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
Lecture 4: Digital Systems & Binary Numbers (4)
Integers’ Representation. Binary Addition. Two's Complement.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Data Representation in Computer Systems
Computer Architecture & Operations I
Data Representation – Chapter 3
CPS120: Introduction to Computer Science
COMS 361 Computer Organization
Chapter 1 (Part c) Digital Systems and Binary Numbers
Two’s Complement & Binary Arithmetic
Presentation transcript:

Integers’ Representation. Binary Addition. Two's Complement. Unsigned number representation Binary Addition, Subtraction. Overflow of unsigned numbers. Negative integers’ representation. Sign Magnitude. Complement number systems One’s complement Two’s complement. Addition. Subtraction. Overflow. Textbook: Ch4, pages Central Connecticut State University, MIPS Tutorial. Chapter 8. Wakerly: Chapter 2. NUMBER SYSTEMS AND CODES

The representation of the numbers in the computers should satisfy the following requirements:  Be comfortable for keeping them in the memory (take less hardware for storing).  Be comfortable for calculations (need less hardware and act faster). Number representation requirements The operations we do with the numbers in the computers are:  Addition  Subtraction  Multiplication  Division  Comparison

Number representation examples We can represent at most 4 unsigned numbers with these 4 patterns. This way: Or this way: For transmission through the noisy channels we use some redundancy to be able to recover the information after transmitting We use only 2 patterns from 8 for representing 2 numbers. Then if at the receiver side we got “110” then we can assume that it was “1” when it was sent. Number of possible patterns of N bits = 2 N How to assign these patters to the numbers we want to represent ? It depends on our choice based on requirements of the task we want to implement.

 The representation of the decimal positive numbers in natural binary positional form in the computers is called “Unsigned” representation. Unsigned number representation This is the unsigned representation of positive numbers 0-7 on 3 bits.

Binary Addition Algorithm Binary Addition Table the carry into the column | < oprnd oprnd ^ | the carry out of the column Definition: Two bit patterns representing two integers are manipulated to create a third pattern which represents the sum of the integers. Definition: Two bit patterns representing two integers are manipulated to create a third pattern which represents the sum of the integers. To add two bits:  Count the number of ones in a column and write the result in binary.  The right bit of the result is placed under the column of bits.  The left bit is called the "carry out of the column". To add two bits:  Count the number of ones in a column and write the result in binary.  The right bit of the result is placed under the column of bits.  The left bit is called the "carry out of the column".

To add two N-bit (representations of) integers:  Proceed from right-to-left, column-by-column, until you reach the leftmost column.  For each column, perform 1-bit addition.  Write the carry-out of each column above the column to its left. The bit is the left column's carry-in. Binary addition of N bits An addition example with 4 bits ==> 0111 ==> 0111 ==> 0111 ==> = = = = = =

 Usually the operands and the result have a fixed number of bits (usually 8, 16, 32, or 64). These are the sizes that processors use to represent integers.  If the bits in the leftmost columns of the sum are zero, include them in the answer to keep the result the same bit-length as the operands.  Compute the carry-out of the leftmost column, but don't write it as part of the answer (because there is no room.) Binary addition details

Unsigned overflow  When the bit patterns are regarded as representing positive integers (unsigned binary representation), a carry-out of 1 from the leftmost column means the sum does not fit into the fixed number of bits.  This is called Overflow.  When the bit patterns are regarded as representing positive and negative integers (as described in the last pages of this chapter), then a carry-out of 1 from the leftmost column  is not necessarily overflow.  When the bit patterns are regarded as representing positive integers (unsigned binary representation), a carry-out of 1 from the leftmost column means the sum does not fit into the fixed number of bits.  This is called Overflow.  When the bit patterns are regarded as representing positive and negative integers (as described in the last pages of this chapter), then a carry-out of 1 from the leftmost column  is not necessarily overflow Correct Unsigned Binary Addition The result is CORRECT only if the CARRY OUT of the high order column is ZERO.

Unsigned subtraction An Example with 4 bits minuend subtrahend difference The borrowing of the values is done from the previous columns similar to 10 based arithmetic. Just instead of 10 the 2 is borrowed (10 binary). Pros and Cons Unsigned numbers represent only positive integers Addition is simple. Subtraction is complex.