types of errors part 5

Upload: harris-anches

Post on 03-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 types of errors part 5

    1/21

    6/12/2013 http://numericalmethods.eng.usf.edu 1

    Floating Point Representation

    Major: All Engineering Majors

    Authors: Autar Kaw, Matthew Emmons

    http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM

    Undergraduates

    http://numericalmethods.eng.usf.edu/http://numericalmethods.eng.usf.edu/
  • 7/28/2019 types of errors part 5

    2/21

    Floating Point Representation

    http://numericalmethods.eng.usf.edu

    http://numericalmethods.eng.usf.edu/http://numericalmethods.eng.usf.edu/
  • 7/28/2019 types of errors part 5

    3/21

    http://numericalmethods.eng.usf.edu3

    Floating Decimal Point : Scientific Form

    2

    3

    2

    10.56782aswrittenis78.256

    10678.3aswrittenis003678.0105678.2aswrittenis78.256

  • 7/28/2019 types of errors part 5

    4/21

    http://numericalmethods.eng.usf.edu4

    Example

    exponent10mantissasignThe form is

    or

    Example: For

    em 10

    2105678.2

    2

    5678.2

    1

    e

    m

  • 7/28/2019 types of errors part 5

    5/21

    http://numericalmethods.eng.usf.edu5

    Floating Point Format for BinaryNumbers

    mm

    m y e

    22 101mantissave-for 1ve,for 0number of sign

    2

    1 is not stored as it is always given to be 1.

    exponentinteger e

  • 7/28/2019 types of errors part 5

    6/21

    http://numericalmethods.eng.usf.edu6

    Example

    22

    52210

    1011011.1

    21011011.111.11011075.54

    9 bit-hypothetical wordthe first bit is used for the sign of the number,the second bit for the sign of the exponent,the next four bits for the mantissa, and

    the next three bits for the exponent

    We have the representation as

    0 0 1 0 1 1 1 0 1

    Sign of thenumber

    mantissaSign of theexponent

    exponent

  • 7/28/2019 types of errors part 5

    7/21

    http://numericalmethods.eng.usf.edu7

    Machine EpsilonDefined as the measure of accuracy and foundby difference between 1 and the next number

    that can be represented

  • 7/28/2019 types of errors part 5

    8/21

  • 7/28/2019 types of errors part 5

    9/21

    http://numericalmethods.eng.usf.edu9

    Relative Error and MachineEpsilon

    The absolute relative true error in representinga number will be less then the machine epsilon

    Example

    201102

    5210

    21100.1

    21100.102832.0

    10 bit word (sign, sign of exponent, 4 for exponent, 4 for mantissa)

    0 1 0 1 1 0 1 1 0 0

    0625.02034472.0

    02832.00274375.002832.0

    0274375.021100.1

    4

    01102

    2

    a

    Sign of thenumber mantissaSign of theexponent

    exponent

  • 7/28/2019 types of errors part 5

    10/21

    IEEE 754 Standards for SinglePrecision Representation

    http://numericalmethods.eng.usf.edu

  • 7/28/2019 types of errors part 5

    11/21

    IEEE-754 Floating PointStandard

    Standardizes representation of floating point numbers on

    different computers in single anddouble precision.

    Standardizes representation of floating point operations ondifferent computers.

  • 7/28/2019 types of errors part 5

    12/21

    One Great Reference

    What every computer scientist (and even if you are not) should know about floating point

    arithmetic!

    http://www.validlab.com/goldberg/paper.pdf

    http://www.validlab.com/goldberg/paper.pdfhttp://www.validlab.com/goldberg/paper.pdf
  • 7/28/2019 types of errors part 5

    13/2113

    IEEE-754 Format Single

    Precision32 bits for single precision

    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

    Sign(s)

    BiasedExponent (e)

    Mantissa (m)

    127'2 21)1(Value . e s m

  • 7/28/2019 types of errors part 5

    14/2114

    Example#1

    127'2 2.11Value e s m

    127)10100010(21 2210100000.11

    127162

    2625.11 1035 105834.52625.11

    1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

    Sign(s)

    BiasedExponent (e)

    Mantissa (m)

  • 7/28/2019 types of errors part 5

    15/2115

    Example#2

    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

    Sign(s)

    BiasedExponent (e)

    Mantissa (m)

    Represent -5.5834x10 10 as a singleprecision floating point number.

    ?110

    2?.11105834.5

  • 7/28/2019 types of errors part 5

    16/2116

    Exponent for 32 Bit IEEE-754

    8 bits would represent2550 e

    Bias is 127; so subtract 127 fromrepresentation

    128127 e

  • 7/28/2019 types of errors part 5

    17/21

    Exponent for Special Casese Actual range of

    2541 e

    0e and 255e are reserved for special numbers

    Actual range of

    127126 e

    e

  • 7/28/2019 types of errors part 5

    18/21

    Special Exponents and Numbers

    0e all zeros255e all ones

    s m Represents0 all zeros all zeros 01 all zeros all zeros -00 all ones all zeros

    1 all ones all zeros0 or 1 all ones non-zero NaN

    e

  • 7/28/2019 types of errors part 5

    19/2119

    IEEE-754 Format

    The largest number by magnitude

    The smallest number by magnitude

    Machine epsilon

    381272 1040.321........1.1

    381262 1018.220......00.1

    723 1019.12mach

  • 7/28/2019 types of errors part 5

    20/21

    Additional ResourcesFor all resources on this topic such as digital audiovisuallectures, primers, textbook chapters, multiple-choice tests,worksheets in MATLAB, MATHEMATICA, MathCad andMAPLE, blogs, related physical problems, please visit

    http://numericalmethods.eng.usf.edu/topics/floatingpoint_representation.html

    http://numericalmethods.eng.usf.edu/topics/floatingpoint_representation.htmlhttp://numericalmethods.eng.usf.edu/topics/floatingpoint_representation.htmlhttp://numericalmethods.eng.usf.edu/topics/floatingpoint_representation.htmlhttp://numericalmethods.eng.usf.edu/topics/floatingpoint_representation.htmlhttp://numericalmethods.eng.usf.edu/topics/floatingpoint_representation.html
  • 7/28/2019 types of errors part 5

    21/21

    THE END

    http://numericalmethods.eng.usf.edu

    http://numericalmethods.eng.usf.edu/http://numericalmethods.eng.usf.edu/