( A + B) (-A)
Download
Report
Transcript ( A + B) (-A)
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 sträng
load (l.s)“987”
to interpret them as
a float
Use a branch or a jump (bne or j) to interpret
them as an instruction
instruktion xor $24, $9, 0x3700
Eight Conditions for SignedMagnitude Addition/Subtraction
Operation
ADD
Magnitudes
(+A) + (+B)
+ (A + B)
SUBTRACT Magnitudes
A>B
A<B
A=B
(+A) + (-B)
+ (A – B )
- (B – A )
+ (A – B )
(-A) + (+B)
- (A – B )
+ (B – A )
+ (A – B )
+ (A – B )
- (B – A )
+ (A – B )
- (A – B )
+ (B – A )
+ (A – B )
(-A) + (-B)
- ( A + B)
(+A) - (+B)
(+A) - (-B)
+ (A + B)
(-A) - (+B)
- ( A + B)
(-A) - (-B)
n
multiplicand
multiplier
partial
product
array
n
can be formed in parallel
and added in parallel for
faster multiplication
double precision product
2n
4
0010
0101
0010
0000
4
Multiplicand = 2
Multiplier = 5
partial
product
array
0010
0000
00001010
2n
00000010
00000100
00001000
00010000
Product = 10
8 bits
2*5 = 10
0101
0010
0001
0000
4 bits
0000000
00000010
00001010
8 bits
Don’t
Add Add
Multiplicand
Add
Multiplicand
Multiplicand
to product
toto
product
product
Don’t Add Multiplicand to product
Optimera....
n
multiplicand
multiplier
partial
product
array
n
can be formed in
parallel and added in
parallel for faster
multiplication
double precision product
2n
Aha!
Multiplicera med
32 = 25
1378 * 32
kompilator
1378 << 5 (shift left 5)
MIPS (IEEE 754)
1
8
23
sign exponent
(-1)
sign
fraction
(exponent - 127)
x (1+fraction) x 2
-127 128
exempel
0.7510 = 0 + 0.5 + 0.25 = ½ + ¼ = 0.112
Normalisera 0.112 = 1.102 x (2-1)10
-0.7510
1
(-1) x (1 + 0.1000...0) x 2
-1
(126 - 127)
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!