IEEE Floating Point Numbers Overview Noah Mendelsohn Tufts University Web: COMP.

Slides:



Advertisements
Similar presentations
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Advertisements

Fabián E. Bustamante, Spring 2007 Floating point Today IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Faculty of Computer Science © 2006 CMPUT 229 Floating Point Representation Operating with Real Numbers.
COMP3221: Microprocessors and Embedded Systems Lecture 14: Floating Point Numbers Lecturer: Hui Wu Session 2, 2004.
University of Washington Today: Floats! 1. University of Washington Today Topics: Floating Point Background: Fractional binary numbers IEEE floating point.
Floating Point Numbers. CMPE12cGabriel Hugh Elkaim 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or.
Floating Point Numbers. CMPE12cCyrus Bazeghi 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or 2 64.
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 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
Computer Science 210 Computer Organization Floating Point Representation.
The IEEE Format for storing float (single precision) data type Use the “enter” key to proceed through the show.
IT 251 Computer Organization and Architecture Introduction to Floating Point Numbers Chia-Chi Teng.
Ch. 2 Floating Point Numbers
Number Systems II Prepared by Dr P Marais (Modified by D Burford)
Factional Values What is 0.75 in binary?. How could we represent fractions? In decimal: – As fractions : 1/5.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
Computing Systems Basic arithmetic for computers.
Floating Point Numbers Topics –IEEE Floating Point Standard –Rounding –Floating Point Operations –Mathematical properties.
Data Representation - Part II. Characters A variable may not be a non-numerical type Character is the most common non- numerical type in a programming.
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,
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
9.4 FLOATING-POINT REPRESENTATION
CSC 221 Computer Organization and Assembly Language
COMP201 Computer Systems Floating Point Numbers. Floating Point Numbers  Representations considered so far have a limited range dependent on the number.
Integer and Fixed Point P & H: Chapter 3
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.
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
IT11004: Data Representation and Organization Floating Point Representation.
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
Numbers in 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.
1 Floating Point. 2 Topics Fractional Binary Numbers IEEE 754 Standard Rounding Mode FP Operations Floating Point in C Suggested Reading: 2.4.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point Representations
2.4. Floating Point Numbers
Floating Point Math & Representation
Topics IEEE Floating Point Standard Rounding Floating Point Operations
Floating Point Number system corresponding to the decimal notation
IEEE floating point format
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
Topic 3d Representation of Real Numbers
Number Representations
CS 61C: Great Ideas in Computer Architecture Floating Point Arithmetic
CS 105 “Tour of the Black Holes of Computing!”
How to represent real numbers
How to represent real numbers
CS 105 “Tour of the Black Holes of Computing!”
October 17 Chapter 4 – Floating Point Read 5.1 through 5.3 1/16/2019
Floating Point Numbers
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
CS213 Floating Point Topics IEEE Floating Point Standard Rounding
COMS 161 Introduction to Computing
Topic 3d Representation of Real Numbers
CS 286 Computer Architecture & Organization
CS 105 “Tour of the Black Holes of Computing!”
Number Representations
Presentation transcript:

IEEE Floating Point Numbers Overview Noah Mendelsohn Tufts University Web: COMP 40: Machine Structure and Assembly Language Programming (Fall 2013)

© 2010 Noah Mendelsohn Note: There are excellent detailed descriptions in Bryant and O’Hallaron. These slides are designed to give you an introduction, and some intuition about why IEEE floating point works the way it does.

© 2010 Noah Mendelsohn What’s Wrong with Integers?

© 2010 Noah Mendelsohn Big numbers 4 Estimated US National Debt as of 7 Oct 2013: $16,753,342,516,305.38* * Source: What if we had only limited space in which to write? Besides, do we really think the 38 cents are meaningful? We’re more likely to say informally: $16.8 trillion A scientist would of course write this as: 1.68 x 10 13

© 2010 Noah Mendelsohn Big numbers 5 Estimated US National Debt as of 7 Oct 2013: $16,753,342,516,305.38* * Source: What if we had only limited space in which to write? Besides, do we really think the 38 cents are meaningful? We’re more likely to say informally: $16.8 trillion A scientist would of course write this as: 1.68 x Key intuition: we can approximate a very large range of numbers using very few digits if we’re willing to lose the less significant digits.

© 2010 Noah Mendelsohn Big numbers 6 Estimated US National Debt as of 7 Oct 2013: $16,753,342,516,305.38* * Source: What if we had only limited space in which to write? Besides, do we really think the 38 cents are meaningful? We’re more likely to say informally: $16.8 trillion A scientist would of course write this as: 1.68 x Warning: this means we may treat $16,753,342,516, and $16,753,976,632, as the same number!

© 2010 Noah Mendelsohn Starting with Decimal IEEE floating point uses binary for both fractions and exponents. Students typically have more intuition for decimal, so we’ll introduce the concepts with decimal first.

© 2010 Noah Mendelsohn Scientific Notation 8 Let’s approximate: $16,753,342,516, using Scientific Notation x 10 13

© 2010 Noah Mendelsohn Exponent Scientific Notation 9 Let’s approximate: $16,753,342,516, using Scientific Notation x Significand Very small numbers: exponent is negative Negative numbers: significand is negative * You may see references to the work “mantissa” – it’s another term for “significand”

© 2010 Noah Mendelsohn Normalized (One non-zero digit left of decimal point) Normalization 10 All of these represent the same number: x Whenever possible IEEE floating point numbers are normalized x x x x 10 15

© 2010 Noah Mendelsohn Floating Point Computer Data Types

© 2010 Noah Mendelsohn Why floating point types?  Need a way to work with very wide range of values  Willing to make same tradeoff as scientific notation –We only carry the high order digits – nearby values not distinguished  What we need –Standardized encoding in bits –Arithmetic and other operations  IEEE 754 floating point is a cross–industry standard* –32 and 64 bit encodings: latter carries more digits & wider range of exponents –Standardized arithmetic including edge cases – usually in hardware –Includes special NaN values for error cases (+/- INFinity) etc. –Subnormal numbers implement gradual underflow (advanced topic) –Most software systems provide math functions (sqrt, sin, cos, atan, etc., etc.)  The IA64 machines we use all implement IEEE floating point which are used for the float (32 bit) and double (64 bit) C types 12

© 2010 Noah Mendelsohn Reminder: how it worked in decimal x 10 1 Decimal 1/10 1/100 1/1000 1/10000 (1/10 + 3/ / /10000) * /8

© 2010 Noah Mendelsohn …but we need to do it in binary! x 2 1 Binary 1/2 1/4 1/8 1/16 (1/2 1/4 1/8 1/16) * 2 2 3/8

© 2010 Noah Mendelsohn Decimal and binary compared 15

© 2010 Noah Mendelsohn IEEE floating point encodes this in 32 bits x bits Huh? That doesn’t look right!

© 2010 Noah Mendelsohn The encoding is a bit tricky  Sign: 1 bit (0 = positive, 1 = negative)  Exponent 8 bits (true exponent + bias of 127)  Significand: 23 bits (as you would expect but without the leading 1 bit) 17 Let’s use our example to make this clearer

© 2010 Noah Mendelsohn IEEE floating point encodes this in 32 bits x bits Sign bit: 0 = positive

© 2010 Noah Mendelsohn IEEE floating point encodes this in 32 bits x bits Exponent is 1… …but we need to add bias = 128 Binary:

© 2010 Noah Mendelsohn IEEE floating point encodes this in 32 bits x bits Remember, there is always a 1 here for normalized numbers…we don’t waste a bit storing it

© 2010 Noah Mendelsohn IEEE floating point encodes this in 32 bits x bits The fraction is stored “left aligned”

© 2010 Noah Mendelsohn IEEE floating point encodes this in 32 bits x bits Implied “binary point” is left of the fraction

© 2010 Noah Mendelsohn A few more details  Why all this trickiness? –Saving bits (e.g. not saving the invariant 1) –Integer compares put positive floating point numbers in sorted order!  There’s also a 64 bit format (the C “double” type) –1 bit sign –11 bit exponent (bias is 1023) –52 bit fraction  There are some details we haven’t covered –Exponent of 0 means denormalized number: provides useful values close to zero. There is no implied “1” and the exponent is fixed at -126 for 32 bit and for 64 bit). These values have less precision. –Exponent of all 1’s denotes special values: +/- Infinity, +/- zero (yes there are both!), Exception values, etc. You should read about this in B&O. 23 You may be tested on both 32 & 64 bit formats