Instructor: Andrew Case Floating Point Slides adapted from Randy Bryant & Dave O’Hallaron.

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.
– 1 – CS213, S’06 Floating Point 4/5/2006 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties CS213.
Floating Point Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties CS 367.
Carnegie Mellon Instructors: Dave O’Hallaron, Greg Ganger, and Greg Kesden Floating Point : Introduction to Computer Systems 4 th Lecture, Sep 6,
1 Binghamton University Floating Point CS220 Computer Systems II 3rd Lecture.
Float’s and reals CENG331: Introduction to Computer Systems 4 th Lecture Instructor: Erol Sahin Acknowledgement: Most of the slides are adapted from the.
Carnegie Mellon Instructors: Randy Bryant & Dave O’Hallaron Floating Point : Introduction to Computer Systems 3 rd Lecture, Aug. 31, 2010.
University of Washington Today: Floats! 1. University of Washington Today Topics: Floating Point Background: Fractional binary numbers IEEE floating point.
University of Washington Today Topics: Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Example and properties.
Floating Point Arithmetic August 25, 2007
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
Floating Point Arithmetic February 15, 2001 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IA32 floating.
FLOATING POINT COMPUTER ARCHITECTURE AND ORGANIZATION.
Floating Point Sept 6, 2006 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties class03.ppt “The course.
Number Systems II Prepared by Dr P Marais (Modified by D Burford)
Floating Point Numbers Topics –IEEE Floating Point Standard –Rounding –Floating Point Operations –Mathematical properties.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Carnegie Mellon Instructors: Seth Copen Goldstein, Anthony Rowe, Greg Kesden Floating Point : Introduction to Computer Systems 4 th Lecture, Jan.
9.4 FLOATING-POINT REPRESENTATION
Carnegie Mellon Instructors: Greg Ganger, Greg Kesden, and Dave O’Hallaron Floating Point : Introduction to Computer Systems 4 th Lecture, Sep 4,
Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Carnegie Mellon Instructor: San Skulrattanakulchai Floating Point MCS-284:
HW 3 Due 3/9 (Mon) 11:00 AM Probs. 2.81, 2.87, 2.88.
Lecture 12: Integer Arithmetic and Floating Point CS 2011 Fall 2014, Dr. Rozier.
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
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.
Floating Point CENG331 - Computer Organization Instructors:
Carnegie Mellon Instructors: Randy Bryant, Dave O’Hallaron, and Greg Kesden Floating Point : Introduction to Computer Systems 4 th Lecture, Sep 5,
IT11004: Data Representation and Organization Floating Point Representation.
Floating Point Arithmetic Feb 17, 2000 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IA32 floating point.
Floating Point Sept 9, 2004 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties class04.ppt “The course.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
1 University of Washington Fractional binary numbers What is ?
University of Washington Floating-Point Numbers The Hardware/Software Interface CSE351 Winter 2013.
1 Floating Point. 2 Topics Fractional Binary Numbers IEEE 754 Standard Rounding Mode FP Operations Floating Point in C Suggested Reading: 2.4.
Floating Point Carnegie Mellon /18-243: Introduction to Computer Systems 4 th Lecture, 26 May 2011 Instructors: Gregory Kesden.
Lecture 4 IEEE 754 Floating Point Topics IEEE 754 standard Tiny float January 25, 2016 CSCE 212 Computer Architecture.
Floating Point Topics IEEE Floating-Point Standard Rounding Floating-Point Operations Mathematical Properties CS 105 “Tour of the Black Holes of Computing!”
Floating Point Arithmetic Sept. 24, 1998 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Alpha floating.
Floating Point Representations
Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Carnegie Mellon Today’s Instructor: Randy Bryant Floating Point :
Data analysis and modeling: the tools of the trade
Floating Point CSE 238/2038/2138: Systems Programming
Floating Point Borrowed from the Carnegie Mellon (Thanks, guys!)
Floating Point Numbers
CS 105 “Tour of the Black Holes of Computing!”
2.4. Floating Point Numbers
Topics IEEE Floating Point Standard Rounding Floating Point Operations
CS 105 “Tour of the Black Holes of Computing!”
CS 367 Floating Point Topics (Ch 2.4) IEEE Floating Point Standard
Floating Point.
Topic 3d Representation of Real Numbers
CS201 - Lecture 5 Floating Point
CS 105 “Tour of the Black Holes of Computing!”
How to represent real numbers
CS 105 “Tour of the Black Holes of Computing!”
Floating Point Arithmetic August 31, 2009
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
CS213 Floating Point Topics IEEE Floating Point Standard Rounding
Topic 3d Representation of Real Numbers
IT11004: Data Representation and Organization
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
Presentation transcript:

Instructor: Andrew Case Floating Point Slides adapted from Randy Bryant & Dave O’Hallaron

2 Today: Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Floating point in C

3 Fractional binary numbers What is ?

4 2i2i 2 i /2 1/4 1/8 2 -j bibi b i-1 b2b2 b1b1 b0b0 b -1 b -2 b -3 b -j Fractional Binary Numbers Representation  Bits to right of “binary point” represent fractional powers of 2  Represents rational number:

5 Fractional Binary Numbers: Examples ValueRepresentation 5 3/ / / Observations  Divide by 2 by shifting right  Multiply by 2 by shifting left  Numbers of form … 2 are just below 1.0  1/2 + 1/4 + 1/8 + … + 1/2 i + … ➙ 1.0  Use notation 1.0 – ε

6 Representable Numbers Limitation  Can only exactly represent numbers of the form x/2 k  Other rational numbers have repeating bit representations ValueRepresentation  1/ [01]… 2  1/ [0011]… 2  1/ [0011]… 2

7 Today: Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Floating point in C

8 IEEE Floating Point IEEE Standard 754  Established in 1985 as uniform standard for floating point arithmetic  Before that, many idiosyncratic formats  Supported by all major CPUs Driven by numerical concerns  Nice standards for rounding, overflow, underflow  Hard to make fast in hardware  Numerical analysts predominated over hardware designers in defining standard

9 Numerical Form: (–1) s M 2 E  Sign bit s determines whether number is negative or positive  Significand M normally a fractional value in range [1.0,2.0).  Exponent E weights value by power of two Encoding  MSB s is sign bit s  exp field encodes E (but is not equal to E)  frac field encodes M (but is not equal to M) Floating Point Representation sexpfrac

10 Precisions Single precision: 32 bits Double precision: 64 bits sexpfrac 18-bits23-bits sexpfrac 111-bits52-bits

11 Normalized Encoding Example Value: Float F = ;  = = x 2 13 Significand M = frac= Exponent E = 13 Bias = 127 Exp = 140 = Result: sexpfrac

12 Today: Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Floating point in C

13 Floating Point in C C Guarantees Two Levels  float single precision  double double precision Conversions/Casting  Casting between int, float, and double changes bit representation  double / float → int  Truncates fractional part  Like rounding toward zero  Not defined when out of range or NaN: Generally sets to TMin  int → double  Exact conversion, as long as int has ≤ 53 bit word size  int → float  Will round according to rounding mode

14 Summary Don’t compare floating point numbers just for equality` if (fabs(result – expectedResult) < )