lecture 5 floating point continued
play

Lecture 5 Floating Point Continued CS 230 - Spring 2020 1-1 - PowerPoint PPT Presentation

CS 230 Introduction to Computers and Computer Systems Lecture 5 Floating Point Continued CS 230 - Spring 2020 1-1 Normalized Representation Why do we need to move the radix point to after the first 1 bit? Why is there a 1 in the


  1. CS 230 – Introduction to Computers and Computer Systems Lecture 5 – Floating Point Continued CS 230 - Spring 2020 1-1

  2. Normalized Representation  Why do we need to move the radix point to after the first 1 bit? Why is there a 1 in the formula?  (-1) S * 1 .F * 2 E-B  Let’s pretend it’s a zero: consider 1.01 2  In our example format it could be  (-1) 0 * 0 .1010 * 2 4-3  (-1) 0 * 0 .0101 * 2 5-3  Now we can’t compare bits for equality and we waste the potential free 1 bit CS 230 - Spring 2020 1-2

  3. Normalized Representation Problem  What is the smallest positive number we can represent in our example format?  (-1) S * 1 .F * 2 E-B  S=0 E=000 F=0001  (-1) 0 * 1 .0001 * 2 0-3 = 1 .0001 * 2 -3 = 0.00 1 0001 2  How do we get rid of that 1?  It’s blocking all the small numbers  We can’t just always use zero instead CS 230 - Spring 2020 1-3

  4. Solution: Subnormal  Only use zero when the number is too small  Two forms of the floating point formula Normal: (-1) S * (1 + F) * 2 E-B Subnormal: (-1) S * (0 + F) * 2 1-B  How do we know when to use which form? - When E is all zeros use subnormal  Why 1-B? - We used up E=0 to mean subnormal, so now smallest exponent is E=1 and we don’t want to leave a gap CS 230 - Spring 2020 1-4

  5. Special Cases  Overflow still possible (E too large)  represent as +/- infinity  also for division by zero (by IEEE standard)  Invalid result – Not a Number – NaN  special cases, like 0/0 or ∞ *0 or sqrt(-1)  can “safely” propagate during computation  Both can propagate during computation  no exception (like integer division by zero) CS 230 - Spring 2020 1-5

  6. IEEE-754 Special Cases Exponent Fraction Case 000000… 000000… 0 000000… non-zero subnormal 111111… 000000… infinity (+ or -) 111111… non-zero NaN anything else anything normal CS 230 - Spring 2020 1-6

  7. CS 230 - Spring 2020 1-7

  8. CS 230 - Spring 2020 1-8

  9. CS 230 - Spring 2020 1-9

  10. CS 230 - Spring 2020 1-10

  11. CS 230 - Spring 2020 1-11

  12. CS 230 - Spring 2020 1-12

  13. CS 230 - Spring 2020 1-13

  14. CS 230 - Spring 2020 1-14

  15. CS 230 - Spring 2020 1-15

  16. CS 230 - Spring 2020 1-16

  17. CS 230 - Spring 2020 1-17

  18. CS 230 - Spring 2020 1-18

  19. CS 230 - Spring 2020 1-19

  20. CS 230 - Spring 2020 1-20

  21. CS 230 - Spring 2020 1-21

  22. CS 230 - Spring 2020 1-22

  23. CS 230 - Spring 2020 1-23

  24. CS 230 - Spring 2020 1-24

  25. CS 230 - Spring 2020 1-25

  26. CS 230 - Spring 2020 1-26

  27. CS 230 - Spring 2020 1-27

  28. CS 230 - Spring 2020 1-28

  29. CS 230 - Spring 2020 1-29

  30. CS 230 - Spring 2020 1-30

  31. CS 230 - Spring 2020 1-31

  32. CS 230 - Spring 2020 1-32

  33. CS 230 - Spring 2020 1-33

  34. CS 230 - Spring 2020 1-34

  35. Floating Point Arithmetic  Addition  align radix points  use normal addition  Multiplication  add exponents  multiply significands  1.F if normal, 0.F if subnormal CS 230 - Spring 2019 1-35

  36. CS 230 - Spring 2020 1-36

  37. CS 230 - Spring 2020 1-37

  38. CS 230 - Spring 2020 1-38

  39. CS 230 - Spring 2020 1-39

  40. CS 230 - Spring 2020 1-40

  41. CS 230 - Spring 2020 1-41

  42. CS 230 - Spring 2020 1-42

  43. CS 230 - Spring 2020 1-43

  44. CS 230 - Spring 2020 1-44

  45. CS 230 - Spring 2020 1-45

  46. CS 230 - Spring 2020 1-46

  47. CS 230 - Spring 2020 1-47

  48. CS 230 - Spring 2020 1-48

  49. CS 230 - Spring 2020 1-49

  50. CS 230 - Spring 2020 1-50

  51. CS 230 - Spring 2020 1-51

  52. CS 230 - Spring 2020 1-52

  53. CS 230 - Spring 2020 1-53

  54. CS 230 - Spring 2020 1-54

  55. CS 230 - Spring 2020 1-55

  56. CS 230 - Spring 2020 1-56

  57. CS 230 - Spring 2020 1-57

  58. CS 230 - Spring 2020 1-58

  59. CS 230 - Spring 2020 1-59

  60. CS 230 - Spring 2020 1-60

  61. CS 230 - Spring 2020 1-61

  62. CS 230 - Spring 2020 1-62

  63. CS 230 - Spring 2020 1-63

  64. CS 230 - Spring 2020 1-64

  65. CS 230 - Spring 2020 1-65

  66. CS 230 - Spring 2020 1-66

  67. CS 230 - Spring 2020 1-67

Recommend


More recommend