1 / 12

Floating Point (a brief look)

Learn about IEEE 754 floating point standard, representation of numbers with fractions, complexities of floating point operations, implementation challenges, and handling special symbols. Gain insights into floating point multiplication, accuracy, and rounding modes.

woodsmark
Download Presentation

Floating Point (a brief look)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Floating Point (a brief look) • We need a way to represent • numbers with fractions, e.g., 3.1416 • very small numbers, e.g., .000000001 • very large numbers, e.g., 3.15576 ´ 109 • Representation: • sign, exponent, significand: (–1)sign´ significand ´ 2exponent • 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

  2. 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´ (1+significand) ´ 2exponent – bias • Example: • decimal: -.75 = -3/4 = -3/22 • binary: -.11 = -1.1 x 2-1 • floating point: exponent = 126 = 01111110 • IEEE single precision: 10111111010000000000000000000000

  3. Floating Point Complexities • Operations are somewhat more complicated (see text) • In addition to overflow we can have “underflow” • Accuracy can be a big problem • IEEE 754 keeps two extra bits, guard and round • four rounding modes • positive divided by zero yields “infinity” • zero divide by zero yields “not a number” • other complexities • Implementing the standard can be tricky • Not using the standard can be even worse • see text for description of 80x86 and Pentium bug!

  4. S i g n E x p o n e n t S i g n i f i c a n d S i g n E x p o n e n t S i g n i f i c a n d S m a l l A L U E x p o n e n t d i f f e r e n c e 0 1 0 1 0 1 C o n t r o l S h i f t r i g h t B i g A L U S h i f t l e f t o r r i g h t R o u n d i n g h a r d w a r C o m p a r e e x p o n e n t s S h i f t s m a l l e r n u m b e r r i g h t A d d 0 1 0 1 I n c r e m e n t o r N o r m a l i z e d e c r e m e n t R o u n d e S i g n E x p o n e n t S i g n i f i c a n d

  5. Floating point Multiplication • Multiply mantissas and add exponents • Steps: • Add exponents • Multiply mantissas • Normalise result • Round results • Fix sign of product

  6. Floating Accuracy • Floating point Numbers are normally approximations for the numbers they represent • IEEE-754 keeps two extra bits on the right during intermediate calculations called guard and round respectively • Example: add 2.56ten * 100 to 2.34ten*102 assumming three significant digits • First with guard and round digits and • then without them

  7. Floating Point Accuracy • Four Rounding modes : • round to nearest (default) • round towards plus infinity • round towards minus infinity • round towards 0

  8. Examples

  9. Special Symbols • Special symbols used by IEEE-754 • + or -  (largest exponent with 0 mantissa) (result of divide by zero) • NaN (Not a number) (largest exponent with 0 mantissa) (0/0 or  - ) • Unnormalised Numbers (no explicit 1 in MSB) (0 exponent non-zero mantissa) • Zero (zero Mantissa and zero expeonent)

  10. Summary

More Related