1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos.

Slides:



Advertisements
Similar presentations
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
Advertisements

CSCE 212 Chapter 3: Arithmetic for Computers Instructor: Jason D. Bakos.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Booth’s Algorithm.
1  2004 Morgan Kaufmann Publishers Chapter Three.
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
MIPS Architecture Multiply/Divide Functions & Floating Point Chapter 4
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Arithmetic.
Computer Architecture ALU Design : Division and Floating Point
Computing Systems Basic arithmetic for computers.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
9.4 FLOATING-POINT REPRESENTATION
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Spring 2006 University of Ilam.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Lecture 9: Floating Point
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Ilam University.
CSC 221 Computer Organization and Assembly Language
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5,
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
CDA 3101 Spring 2016 Introduction to Computer Organization
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Arithmetic for Computers Chapter 3 1. Arithmetic for Computers  Operations on integers  Addition and subtraction  Multiplication and division  Dealing.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Dr. Clincy Professor of CS
Dr. Clincy Professor of CS
Integer Division.
Lecture 9: Floating Point
CS 232: Computer Architecture II
CS/COE0447 Computer Organization & Assembly Language
Morgan Kaufmann Publishers
CDA 3101 Summer 2007 Introduction to Computer Organization
William Stallings Computer Organization and Architecture 7th Edition
CSCE 350 Computer Architecture
CSCI206 - Computer Organization & Programming
Number Representations
How to represent real numbers
ECEG-3202 Computer Architecture and Organization
Chapter 8 Computer Arithmetic
Topic 3d Representation of Real Numbers
Number Representations
Presentation transcript:

1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos

2 Binary Division Like last lecture, we’ll start with some basic terminology… –Again, let’s assume our numbers are base 10, but let’s only use 0’s and 1’s

3 Binary Division Recall: –Dividend=Quotient*Divisor + Remainder Let’s assume that both the dividend and divisor are positive and hence the quotient and the remainder are nonnegative The division operands and both results are 32-bit values and we will ignore the sign for now

4 First Hardware Design for Divider Initialize the Quotient register to 0, initialize the left-half of the Divisor register with the divisor, and initialize the Remainder register with the dividend (right-aligned)

5 Second Hardware Design for Divider Also, the algorithm must be changed so the remainder is shifted left before the subtraction takes place Much like with the multiplier, the divisor and ALU can be reduced to 32-bits if we shift the remainder right instead of shifting the divisor to the left

6 Third Hardware Design for Divider Shift the bits of the quotient into the remainder register… Also, the last step of the algorithm is to shift the left half of the remainder right 1 bit

7 Signed Division Simplest solution: remember the signs of the divisor and the dividend and then negate the quotient if the signs disagree The dividend and the remainder must have the same signs

8 Considerations The same hardware can be used for both multiply and divide –Requirement: 64-bit register that can shift left or right and a 32-bit ALU that can add or subtract

9 Floating Point Floating point (also called real) numbers are used to represent values that are fractional or that are too big to fit in a 32- bit integer Floating point numbers are expressed in scientific notation (base 2) and are normalized (no leading 0’s) –1.xxxx 2 * 2 yyyy In this case, xxxx is the significand and yyyy is the exponent

10 Floating Point In MIPS, a floating point is represented in the following manner (IEEE 754 standard): –bit 31: sign of significand –bit (8) exponent (2’s comp) –bit (23) significand –Note that size of exponent and significand must be traded off... accuracy vs. range This allows us representation for signed numbers as small as 2x to 2x10 38 Overflow and underflow must be detected Double-precision floating point numbers are 2 words... the significand is extended to 52 bits and the exponent to 11 bits Also, the first bit of the significand is implicit (only the fractional part is specified) In order to represent 0 in a float, put 0 in the exponent field –So here’s the equation we use: (-1) S x (1+Significand) x 2 E –Or: (-1) S X (1+ (s1x2 -1 ) + (s2x2 -2 ) + (s3x2 -3 ) + (s4x2 -4 ) +...) x 2 E

11 Considerations IEEE 754 sought to make floating- point numbers easier to sort –sign is first bit –exponent comes first But we want an all-0 (+1) exponent to represent the most-negative exponent and an all-1 exponent to be the most positive This is called biased-notation, so we’ll use the following equation: –(-1) S x (1 + Significand) x 2 (Exponent-Bias) –Bias is 127 for single-precision and 1023 for double-precision