Computer Architecture & Operations I Instructor: Ryan Florin
Floating Point Numbers Morgan Kaufmann Publishers 29 May, 2018 Floating Point Numbers 3.1415926535897 6.022 x 10^23 16.2 119 What do you call a decimal point in binary? Chapter 3 — Arithmetic for Computers
Scientific Notation (base 10) Takes the form: a x 10^b Normalized form ensures there is only 1 non-zero number to the left of the decimal point. 300 => 3.0 x 10^2 142.001 => 1.42001 x 10^2 .0000585 => 5.85 x 10^-5
Scientific Notation (base 2) Takes the form a X 2^b Normalized form ensures there is only 1 non-zero number to the left of the “binary” point. -6.84 => -1.71 x 2^2 .05 => 1.6 x 2^-5
Normalizing binary R = a x 2^b Step 1: Find the power of 2 that is the closest to the number without going over. This is the value of b. Step 2: divide R by 2^b to get the value of a. Example: 6.84 Step 1: b = 2 (2^2 = 4) Step 2: 6.84 / 4 = 1.71 a = 1.71 1.71 x 2^2
IEEE 754 Single Precision (-1)signbit x (1 + fraction) x 2 exponent – bias Single Precision bias: 127 Range: 2^128 – 2^-127 Precision: ~7 digits
Single Precision Example: 3.14 3.14 is positive. Sign bit = 0 a x 2^b 3.14 is between 2^1 and 2^2 (2 and 4) a = 3.14 / 2 = 1.57 Exponential = 1 + bias = 128 (10000000) Fraction = 1.57
Single Precision Example: 3.14 Fraction = 1.57 Due to being normalized, there will always be a 1 to the left of the binary point. It is assumed to be a 1. Represent the rest (.57) using negative powers of 2 .57 = 2-1 + 2-4 + 2-8 + 2-9 + 2-10 + 2-11 + 2-13 + 2-15 + 2-16 + 2-17 + 2-22 Fraction: 10010001111010111000010
Single Precision Example: 3.14 Sign bit: 0 Exponential: 1000 0000 Fraction: 100 1000 1111 0101 1100 0010 0100 0000 0100 1000 1111 0101 1100 0010
IEEE 754 Double Precision (-1)signbit x (1 + fraction) x 2 exponent – bias Double Precision bias: 1023 Range: 2^1024 – 2^-1023 Precision: ~16 digits
Double Precision Example: .0025 .0025 is positive. Sign bit = 0 a x 2^b b = -9: .0025 is between 2^-9 and 2^-8 (.002 and .004) a = .0025 / 2^-9 = 1.28 Exponential = -9 + bias = 1014(11 1111 0110) Fraction = 1.28
Double Precision Example: .0025 Fraction = 1.28 Due to being normalized, there will always be a 1 to the left of the binary point. It is assumed to be a 1. Represent the rest (.28) using negative powers of 2 .28 = 0100 0111 1010 1110 0001 0100 0111 1010 1110 0001 0100 0111 1011
Double Precision Example: .0025 Sign bit: 0 Exponential: 011 1111 0110 Fraction: 0011 1111 0110 0100 0111 1010 1110 0001 0100 0111 1010 1110 0001 0100 0111 1011
Reverse Process Example: 412C000016 0100 0001 0010 1100 0000 0000 0000 Sign bit: 0 Positive Exponential: 1000 0010 130 – 127 = 3 Fraction: 010 1100 0000 0000 0000 2-2 + 2-4 + 2-5 = .5 + .0625 + .03125 = .34375 1.34375 -10 + 1.34375 x 23 = 10.75
What I want you to do Review Chapters 3.5 Review Midterm II