140 likes | 384 Views
Computer Arithmetic. Integer and Fixed Point P & H: Chapter 3. Single Precision IEEE 754 Example (1). Ex : 3.8125 10 = +1.11101 * 2 1 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
E N D
Computer Arithmetic Integer and Fixed Point P & H: Chapter 3
Single Precision IEEE 754 Example (1) 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 (2) 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
Exceptions to IEEE 754 • 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 754 • 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
Test Yourself • Using Single Precision IEEE 754, what is FF28 0000 (Big Endian)? • Using Single Precision IEEE 754, what is 8038 0000 (Big Endian)?