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

lecture 5 floating point continued
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CS 230 - Spring 2020 1-1

CS 230 – Introduction to Computers and Computer Systems Lecture 5 – Floating Point Continued

slide-2
SLIDE 2

CS 230 - Spring 2020 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 * 2E-B

 Let’s pretend it’s a zero: consider 1.012  In our example format it could be

 (-1)0 * 0.1010 * 24-3  (-1)0 * 0.0101 * 25-3

 Now we can’t compare bits for equality and we

waste the potential free 1 bit

slide-3
SLIDE 3

CS 230 - Spring 2020 1-3

Normalized Representation Problem

 What is the smallest positive number we can

represent in our example format?

 (-1)S * 1.F * 2E-B

 S=0 E=000 F=0001  (-1)0 * 1.0001 * 20-3 = 1.0001 * 2-3 = 0.00100012

 How do we get rid of that 1?

 It’s blocking all the small numbers  We can’t just always use zero instead

slide-4
SLIDE 4

CS 230 - Spring 2020 1-4

Solution: Subnormal

 Only use zero when the number is too small  Two forms of the floating point formula

Normal: (-1)S * (1 + F) * 2E-B Subnormal: (-1)S * (0 + F) * 21-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

slide-5
SLIDE 5

CS 230 - Spring 2020 1-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)

slide-6
SLIDE 6

CS 230 - Spring 2020 1-6

IEEE-754 Special Cases

Exponent Fraction Case 000000… 000000… 000000… non-zero subnormal 111111… 000000… infinity (+ or -) 111111… non-zero NaN anything else anything normal

slide-7
SLIDE 7

CS 230 - Spring 2020 1-7

slide-8
SLIDE 8

CS 230 - Spring 2020 1-8

slide-9
SLIDE 9

CS 230 - Spring 2020 1-9

slide-10
SLIDE 10

CS 230 - Spring 2020 1-10

slide-11
SLIDE 11

CS 230 - Spring 2020 1-11

slide-12
SLIDE 12

CS 230 - Spring 2020 1-12

slide-13
SLIDE 13

CS 230 - Spring 2020 1-13

slide-14
SLIDE 14

CS 230 - Spring 2020 1-14

slide-15
SLIDE 15

CS 230 - Spring 2020 1-15

slide-16
SLIDE 16

CS 230 - Spring 2020 1-16

slide-17
SLIDE 17

CS 230 - Spring 2020 1-17

slide-18
SLIDE 18

CS 230 - Spring 2020 1-18

slide-19
SLIDE 19

CS 230 - Spring 2020 1-19

slide-20
SLIDE 20

CS 230 - Spring 2020 1-20

slide-21
SLIDE 21

CS 230 - Spring 2020 1-21

slide-22
SLIDE 22

CS 230 - Spring 2020 1-22

slide-23
SLIDE 23

CS 230 - Spring 2020 1-23

slide-24
SLIDE 24

CS 230 - Spring 2020 1-24

slide-25
SLIDE 25

CS 230 - Spring 2020 1-25

slide-26
SLIDE 26

CS 230 - Spring 2020 1-26

slide-27
SLIDE 27

CS 230 - Spring 2020 1-27

slide-28
SLIDE 28

CS 230 - Spring 2020 1-28

slide-29
SLIDE 29

CS 230 - Spring 2020 1-29

slide-30
SLIDE 30

CS 230 - Spring 2020 1-30

slide-31
SLIDE 31

CS 230 - Spring 2020 1-31

slide-32
SLIDE 32

CS 230 - Spring 2020 1-32

slide-33
SLIDE 33

CS 230 - Spring 2020 1-33

slide-34
SLIDE 34

CS 230 - Spring 2020 1-34

slide-35
SLIDE 35

CS 230 - Spring 2019 1-35

Floating Point Arithmetic

 Addition

 align radix points  use normal addition

 Multiplication

 add exponents  multiply significands

 1.F if normal, 0.F if subnormal

slide-36
SLIDE 36

CS 230 - Spring 2020 1-36

slide-37
SLIDE 37

CS 230 - Spring 2020 1-37

slide-38
SLIDE 38

CS 230 - Spring 2020 1-38

slide-39
SLIDE 39

CS 230 - Spring 2020 1-39

slide-40
SLIDE 40

CS 230 - Spring 2020 1-40

slide-41
SLIDE 41

CS 230 - Spring 2020 1-41

slide-42
SLIDE 42

CS 230 - Spring 2020 1-42

slide-43
SLIDE 43

CS 230 - Spring 2020 1-43

slide-44
SLIDE 44

CS 230 - Spring 2020 1-44

slide-45
SLIDE 45

CS 230 - Spring 2020 1-45

slide-46
SLIDE 46

CS 230 - Spring 2020 1-46

slide-47
SLIDE 47

CS 230 - Spring 2020 1-47

slide-48
SLIDE 48

CS 230 - Spring 2020 1-48

slide-49
SLIDE 49

CS 230 - Spring 2020 1-49

slide-50
SLIDE 50

CS 230 - Spring 2020 1-50

slide-51
SLIDE 51

CS 230 - Spring 2020 1-51

slide-52
SLIDE 52

CS 230 - Spring 2020 1-52

slide-53
SLIDE 53

CS 230 - Spring 2020 1-53

slide-54
SLIDE 54

CS 230 - Spring 2020 1-54

slide-55
SLIDE 55

CS 230 - Spring 2020 1-55

slide-56
SLIDE 56

CS 230 - Spring 2020 1-56

slide-57
SLIDE 57

CS 230 - Spring 2020 1-57

slide-58
SLIDE 58

CS 230 - Spring 2020 1-58

slide-59
SLIDE 59

CS 230 - Spring 2020 1-59

slide-60
SLIDE 60

CS 230 - Spring 2020 1-60

slide-61
SLIDE 61

CS 230 - Spring 2020 1-61

slide-62
SLIDE 62

CS 230 - Spring 2020 1-62

slide-63
SLIDE 63

CS 230 - Spring 2020 1-63

slide-64
SLIDE 64

CS 230 - Spring 2020 1-64

slide-65
SLIDE 65

CS 230 - Spring 2020 1-65

slide-66
SLIDE 66

CS 230 - Spring 2020 1-66

slide-67
SLIDE 67

CS 230 - Spring 2020 1-67