110 likes | 311 Views
Datorsystem 1 och Datorarkitektur 1 – föreläsning 8 fredag 9 november 2007. flyttal 0.0001756809651851654052734375. heltal 59985408. 0x39383700. All interpretations are valid. You have to explicitly tell the machine which interpretation you want.
E N D
Datorsystem 1 och Datorarkitektur 1 – föreläsning 8 fredag 9 november 2007
flyttal 0.0001756809651851654052734375 • heltal 59985408 0x39383700 • All interpretations are valid. You have to explicitly tell the machine which interpretation you want. • Use an integer load (lw) to interpret them as an int • Use a floating point load (l.s) to interpret them as a float • Use a branch or a jump (bne or j) to interpret them as an instruction • sträng “987” • instruktion xor $24, $9, 0x3700
n can be formed in parallel and added in parallel for faster multiplication multiplicand multiplier partial product array n double precision product 2n
4 Multiplicand = 2 0010 Multiplier = 5 0101 0010 0000 0010 0000 00001010 partial product array 4 Product = 10 00010000 00000010 00000100 00001000 2n 8 bits 2*5 = 10 0010 0000 0101 0001 4 bits 0000000 00000010 00001010 8 bits Add Multiplicand to product Don’t Add Multiplicand to product Add Multiplicand to product Don’t Add Multiplicand to product
Optimera.... n multiplicand multiplier can be formed in parallel and added in parallel for faster multiplication partial product array n double precision product 2n Aha! Multiplicera med 32 = 25 kompilator 1378 * 32 1378 << 5 (shift left 5)
MIPS (IEEE 754) (-1)sign x (1+fraction) x 2(exponent - 127) exempel 0.7510 = 0 + 0.5 + 0.25 = ½ + ¼ = 0.112 -127 128 Normalisera 0.112 = 1.102 x (2-1)10 -0.7510 (-1)1 x (1 + 0.1000...0) x 2(126- 127) -1 10111111110000000000000000000000
0.1010 = 1/128 + 1/256 + 1/1024 + .... = 000001111.....2 • During the Gulf War in 1991, a U.S. Patriot missile failed to intercept an Iraqi Scud missile, and 28 Americans were killed. • A later study determined that the problem was caused by the inaccuracy of the binary representation of 0.10. • The Patriot incremented a counter once every 0.10 seconds. • It multiplied the counter value by 0.10 to compute the actual time. • However, the (24-bit) binary representation of 0.10 actually corresponds to 0.099999904632568359375, which is off by 0.000000095367431640625. • This doesn’t seem like much, but after 100 hours the time ends up being off by 0.34 seconds—enough time for a Scud to travel 500 meters!