6
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Computer Arithmetic Computer Arithmetic Integer and Fixed Point P & H: Chapter 3

CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Computer Arithmetic Integer and Fixed Point P & H: Chapter 3

Embed Size (px)

Citation preview

Page 1: CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Computer Arithmetic Integer and Fixed Point P & H: Chapter 3

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Computer ArithmeticComputer Arithmetic

Integer and Fixed Point

P & H: Chapter 3

Page 2: CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Computer Arithmetic Integer and Fixed Point P & H: Chapter 3

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Ex: 3.812510 = +1.11101 * 21

• 0 1 0 0 0 0 0 0 0 1 1 1 0 1 0 0 … 0

• Sign is 0 (bit position 31 MSB)

• Exponent is 1 0 0 0 0 0 0 0 (underlined above)– 0111 1111 + 0000 0001 = 1000 0000

• Mantissa is 1.1110100…0 (the leading 1 is assumed in the representation above)

• That’s +1.11101 * 2(128-127) = 1.9062510 * 21 = 3.812510

Single Precision IEEE 754 Example (1)Single Precision IEEE 754 Example (1)

Page 3: CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Computer Arithmetic Integer and Fixed Point P & H: Chapter 3

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

Ex: -4.12510 = -0100.001 = -1.00001 * 22

• 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 … 0

• In HEX: C084 0000 (Big Endian)

• The exponent is the “unsigned stored value” – 127 = 129 – 127 = 2

• That’s -1.000010 * 2(129-127) = -1.03125 * 22 = -4.125

Single Precision IEEE 754 Example (2)Single Precision IEEE 754 Example (2)

Page 4: CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Computer Arithmetic Integer and Fixed Point P & H: Chapter 3

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

• These rules apply when – Exponent 00– Exponent FF (= 25510)

• Special rules apply for these situations

• These special rules provide for– NaN (Not a Number)– +/- Inf (infinity)– +/- 0 (yes, two zeros!)– “unnormalized” numbers allows very very very small values including “machine epsilon”

(the smallest positive number allowed)

Exceptions to IEEE 754Exceptions to IEEE 754

Page 5: CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Computer Arithmetic Integer and Fixed Point P & H: Chapter 3

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

• Special cases: (E is Exponent, F is Mantissa)• If E=255 and F is nonzero, then Value=NaN ("Not a Number")

• If E=255 and F is zero and S is 1, then Value=-Infinity

• If E=255 and F is zero and S is 0, then Value=Infinity

• If E=0 and F is nonzero, then Value=(-1)^S * 2^(-126) * (0.F) These are "unnormalized" values.

• If E=0 and F is zero and S is 1, then Value=-0

• If E=0 and F is zero and S is 0, then Value=0

Exceptions to IEEE 754Exceptions to IEEE 754

Page 6: CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Computer Arithmetic Integer and Fixed Point P & H: Chapter 3

CS 352 : Computer Organization and DesignUniversity of Wisconsin-Eau Claire Dan Ernst

• Using Single Precision IEEE 754, what is FF28 0000 (Big Endian)?

• Using Single Precision IEEE 754, what is 8038 0000 (Big Endian)?

Test YourselfTest Yourself