Integers’ Representation. Binary Addition. Two's Complement.

Slides:



Advertisements
Similar presentations
Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
Advertisements

Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
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
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.
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.
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
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
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
Integers’ Representation. Binary Addition. Two's Complement. Unsigned number representation Binary Addition, Subtraction. Overflow of unsigned numbers.
Integer Multiplication, Division Arithmetic shift Twice the number of places MIPS multiply unit. mult, multu Significant bits Mfhi, mflo, div, divu Arithmetic.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
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 Math CPS120 Introduction to Computer Science Lecture 7.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Lecture 4: Digital Systems & Binary Numbers (4)
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:
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Department of Computer Science Georgia State University
Unit 1 Introduction Number Systems and Conversion.
Cosc 2150: Computer Organization
Integer Multiplication, Division Arithmetic shift
Computer Architecture & Operations I
Array multiplier TU/e Processor Design 5Z032.
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
Digital Systems and Number Systems
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Computer Science 210 Computer Organization
Data Representation in Computer Systems
Computer Architecture & Operations I
William Stallings Computer Organization and Architecture 7th Edition
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Addition and Substraction
Computer Organization and ASSEMBLY LANGUAGE
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
Computer Science 210 Computer Organization
How to represent real numbers
ECEG-3202 Computer Architecture and Organization
Data Representation – Chapter 3
Unit 18: Computational Thinking
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
CPS120: Introduction to Computer Science
Chapter 8 Computer Arithmetic
ECE 331 – Digital System Design
COMS 361 Computer Organization
Chapter3 Fixed Point Representation
Chapter 1 (Part c) Digital Systems and Binary Numbers
Introduction To Number Systems
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: P&H Ch3, Central Connecticut State University, MIPS Tutorial. Chapter 8. Wakerly: Chapter 2. NUMBER SYSTEMS AND CODES

Number representation requirements 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). 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: 0 0 - 0 0 1 - 1 1 0 - 2 1 1 - 3 Or this way: 0 0 - 3 0 1 - 0 1 1 - 1 For transmission through the noisy channels we use some redundancy to be able to recover the information after transmitting.   0 0 0 - 0 0 0 1 - 0 0 1 0 - 0 0 1 1 - 1 1 0 0 - 0 1 0 1 - 1 1 1 0 - 1 1 1 1 - 1 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  =  2N 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.

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

Binary Addition Algorithm 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". Binary Addition Table the carry into the column | 1 1 1 1 0 0 0 0 <--- 1 0 1 0 1 0 1 0 oprnd1 1 1 0 1 1 1 0 0 oprnd2 --- --- --- --- --- --- --- --- 11 10 10 10 10 01 01 00 ^ the carry out of the column

Binary addition of N bits As the decimal results are correct then the binary arithmetic works correctly. 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. 01111 110 0110 1110 = 11010 + 0001 0111 = 2310 --------- ----- 1000 0101 = 13310 An addition example with 4 bits 0 10 110 0110 0110 0110 0110 0110 0110 6 + 0111 ==> 0111 ==> 0111 ==> 0111 ==> 0111 7 ---- ---- ---- ---- ---- -- 1 01 101 1101 13

Binary addition details Are the results correct for all 3 cases? 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.) The second case is not correct because 7+9 != 0 0011 0001 ---- 0100 1111 0111 1001 ---- 0000 0111 0001 ---- 1000

Correct Unsigned Binary Addition 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. 1111 0111 1001 ---- 0000 0111 0001 ---- 1000 Correct Unsigned Binary Addition The result is CORRECT only if the CARRY OUT of the high order column is ZERO.

Unsigned number representation Pros and Cons Unsigned subtraction An Example with 4 bits 0 1 10 - - - 1 0 0 1 9 minuend 0 0 1 1 - 3 subtrahend ---------- --- 0 1 1 0 6 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). Unsigned number representation Pros and Cons Unsigned numbers represent only positive integers Addition is simple. Subtraction is complex.