CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.

Slides:



Advertisements
Similar presentations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Advertisements

Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Datorteknik FloatingPoint bild 1 Floating point Number system corresponding to the decimal notation 1,837 * 10 significand exponent a great number of corresponding.
Faculty of Computer Science © 2006 CMPUT 229 Floating Point Representation Operating with Real Numbers.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
1  2004 Morgan Kaufmann Publishers Chapter Three.
COE 308: Computer Architecture (T032) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (cont.) (Appendix A, Computer Architecture: A Quantitative.
1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos.
CSE 378 Floating-point1 How to represent real numbers In decimal scientific notation –sign –fraction –base (i.e., 10) to some power Most of the time, usual.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Computer Science 210 Computer Organization Floating Point Representation.
Numbers and number systems
Number Systems II Prepared by Dr P Marais (Modified by D Burford)
Computing Systems Basic arithmetic for computers.
Computer Architecture
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
S. Rawat I.I.T. Kanpur. Floating-point representation IEEE numbers are stored using a kind of scientific notation. ± mantissa * 2 exponent We can represent.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
9.4 FLOATING-POINT REPRESENTATION
Floating Point Representations CDA 3101 Discussion Session 02.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Lecture 9: Floating Point
CSC 221 Computer Organization and Assembly Language
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS 61C L3.2.1 Floating Point 1 (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture Floating Point Kurt Meinz inst.eecs.berkeley.edu/~cs61c.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Computer Architecture & Operations I
Floating Point Representations
Lecture 9: Floating Point
Floating Point Number system corresponding to the decimal notation
CS 232: Computer Architecture II
April 2006 Saeid Nooshabadi
William Stallings Computer Organization and Architecture 7th Edition
Chapter 6 Floating Point
Outline Introduction Floating Point Arithmetic Adder Multiplier.
ECE/CS 552: Floating Point
Number Representations
CSCI206 - Computer Organization & Programming
How to represent real numbers
How to represent real numbers
ECEG-3202 Computer Architecture and Organization
Numbers with fractions Could be done in pure binary
Presentation transcript:

CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic

Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers, e.g.,  10 9 Representation: –sign, exponent, significand: (–1) sign  significand  2 exponent –more bits for significand gives more accuracy –more bits for exponent increases range IEEE 754 floating point standard: –single precision: 8 bit exponent, 23 bit significand –double precision: 11 bit exponent, 52 bit significand

Floating point representation: The idea is to normalize all numbers, so the significand has exactly one digit to the left of the decimal point. –12345 = * 10^4 – = * 10^-6 –Do this in binary: x 2^(1011) IEEE FP representation –(+/-) * 2 ^ ( ) –This is single precision –Double precision: 64 bits in all. Where does one need accuracy of that level?

Floating point numbers Representation issues: –sign bit, exponent, significand –Question: how to represent each field –Question: which order to lay them out in a word? –Factor: should be easy to do comparisons (for sorting) For arithmetic, we will have special hardware anyway –Choice: Sign + magnitude representation Sign bit, followed by exponent, then significand (why?) exponent: represented with a “bias”: add 127 (1023 for double precision) significand: assume implicit 1. (so means )

Floating point representation So: –(+/-) x (1 + significand) x 2 ^ (exponent - bias) is the value of a floating point number –Example: –Example: convert -.41 to single precision form

IEEE 754 floating-point standard Leading “1” bit of significand is implicit Exponent is “biased” to make sorting easier –all 0s is smallest exponent all 1s is largest –bias of 127 for single precision and 1023 for double precision –summary: (–1) sign  significand)  2 exponent – bias Example: –decimal: -.75 = -3/4 = -3/2 2 –binary: -.11 = -1.1 x 2 -1 –floating point: exponent = 126 = –IEEE single precision:

Floating point addition The problem is: the exponents of numbers being added may be different –2.0 * 10^ * 10^(-1) –2.0 * 10^ * 10^ 1 : Now we can add them –2.03 * 10 ^1 –But we are not necessarily done! –E.g * 10^ * 10^(-1) –10.07 * 10^0 is not correct form! –Shift again to get the correct form: * 10^1

You can get different results A + B + C = A + (B+C) = (A+B) + C –Right? Can you see a problem? When do you lose bits?

Floating point multiplication Add exponents, but subtract bias Then multiply significands Then normalize