Faculty of Computer Science © 2006 CMPUT 229 Floating Point Representation Operating with Real Numbers.

Slides:



Advertisements
Similar presentations
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Advertisements

Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Floating Point (FLP) Representation A Floating Point value: f = m*r**e Where: m – mantissa or fractional r – base or radix, usually r = 2 e - exponent.
COMP3221: Microprocessors and Embedded Systems Lecture 14: Floating Point Numbers Lecturer: Hui Wu Session 2, 2004.
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 CSE1301 Computer Programming Lecture 30: Real Number Representation.
CSE1301 Computer Programming Lecture 33: Real Number Representation
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
Floating Point Numbers
Representing Real Numbers Using Floating Point Notation Lecture 6 CSCI 1405, CSCI 1301 Introduction to Computer Science Fall 2009.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Computer Science 210 Computer Organization Floating Point Representation.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Numbers and number systems
Information Representation (Level ISA3) Floating point numbers.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Fixed-Point Arithmetics: Part II
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic7: Floating Point José Nelson Amaral.
Computing Systems Basic arithmetic for computers.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
ECE232: Hardware Organization and Design
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
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.
Lecture 9: Floating Point
CSC 221 Computer Organization and Assembly Language
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Floating Point Representation.
CSC 4250 Computer Architectures September 5, 2006 Appendix H. Computer Arithmetic.
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.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
IT11004: Data Representation and Organization Floating Point Representation.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
Floating Point Representations
Computer Science 210 Computer Organization
Floating Point Representations
CSCI206 - Computer Organization & Programming
Lecture 9: Floating Point
Floating Point Number system corresponding to the decimal notation
CS 232: Computer Architecture II
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
William Stallings Computer Organization and Architecture 7th Edition
Number Representations
Computer Science 210 Computer Organization
CS 286 Computer Architecture & Organization
Numbers with fractions Could be done in pure binary
Number Representations
Presentation transcript:

Faculty of Computer Science © 2006 CMPUT 229 Floating Point Representation Operating with Real Numbers

© 2006 Department of Computing Science CMPUT 229 Reading Material  This set of slides is based on the texts by Patt and Patel and by Patterson and Hennessy.  The topics covered in these slides are presented in Section 4.9 of Clements’ textbook.

© 2006 Department of Computing Science CMPUT 229 Representing Large and Small Numbers How would you represent a number such as  in binary? The range (10 23 ) of this number is greater than the range of the 32-bits representation that we have used for integers (2 31  2.14  ). However the precision (6023) of this number is quite small, and can be expressed in a small number of bits. The solution is to use a floating point representation. A floating point representation allocates some bits for the range of the value, some bits for precision, and one bit for the sign. Patt/Patel, pp. 32

© 2006 Department of Computing Science CMPUT 229 Floating Point Representation Most standard floating point representation use: 1 bit for the sign (positive or negative) 8 bits for the range (exponent field) 23 bits for the precision (fraction field) Sexponentfraction 2381 Patt/Patel, pp. 33

© 2006 Department of Computing Science CMPUT 229 Floating Point Representation (example) Sexponentfraction 2381 Thus the exponent is given by: Patt and Patel, pp. 34

© 2006 Department of Computing Science CMPUT 229 Floating Point Representation (example) Sexponentfraction What is the decimal value of the following floating point number? exponent exponent = =(128-8)+3=120+3=123 Patt and Patel, pp. 34

© 2006 Department of Computing Science CMPUT 229 Floating Point Representation (example) Sexponentfraction What is the decimal value of the following floating point number? exponent exponent = =131 Patt and Patel, pp. 35

© 2006 Department of Computing Science CMPUT 229 Floating Point Representation (example) Sexponentfraction What is the decimal value of the following floating point number? exponent exponent =128+2=130 Patt and Patel, pp. 35

© 2006 Department of Computing Science CMPUT 229 Floating Point Sexponentfraction 2381 What is the largest number that can be represented using a 32-bit floating point number using the IEEE 754 format above? exponent exponent =254 Patt and Patel, pp. 35

© 2006 Department of Computing Science CMPUT 229 Floating Point Sexponentfraction 2381 What is the largest number that can be represented in 32 bits floating point using the IEEE 754 format above? exponent actual exponent = = 127 Patt and Patel, pp. 35

© 2006 Department of Computing Science CMPUT 229 Floating Point Sexponentfraction 2381 What is the smallest number (closest to zero) that can be represented in 32 bits floating point using the IEEE 754 format above? exponent actual exponent =0-126 = -126 Patt and Patel, pp. 35

© 2006 Department of Computing Science CMPUT 229 Special Floating Point Representations In the 8-bit field of the exponent we can represent numbers from 0 to 255. We studied how to read numbers with exponents from 0 to 254. What is the value represented when the exponent is 255 (i.e )? An exponent equal 255 = in a floating point representation indicates a special value. When the exponent is equal 255 = and the fraction is 0, the value represented is  infinity. When the exponent is equal 255 = and the fraction is non-zero, the value represented is Not a Number (NaN). Hen/Patt, pp. 301

© 2006 Department of Computing Science CMPUT 229 Double Precision 32-bit floating point representation is usually called single precision representation. A double precision floating point representation requires 64 bits. In double precision the following number of bits are used: 1 sign bit 11 bits for exponent 52 bits for fraction (also called significand)

© 2006 Department of Computing Science CMPUT 229 Floating Point Addition (Decimal) How do we perform the following addition?   Step 1: Align decimal point of the number with smaller exponent (notice lost of precision)   10 1 Step 2: Add significands:   10 1 =  10 1 Step 3: Renormalize the result:  10 1 =  10 2 Step 3: Round-off the result to the representation available:  10 2 =  10 2 Hen/Patt, pp. 281

© 2006 Department of Computing Science CMPUT 229 Floating Point Addition (Example) Convert the numbers and to floating point binary representation, and then perform the binary floating-point addition of these numbers. Which number should have its significand adjusted? Hen/Patt, pp. 283

© 2006 Department of Computing Science CMPUT 229 Floating Point Multiplication (Decimal) Assume that we only can store four digits of the significand and two digits of the exponent in a decimal floating point representation. How would you multiply  by  in this representation? Step 1: Add the exponents: new exponent = = 5 Step 2: Multiply the significands:  Step 3: Normalize the product:  10 5 =  10 6 Step 4: Round-off the product:  10 6 =  10 6 Hen/Patt, pp. 286