In: Advanced Math
Check if (A x B) x C = A x (B x C) using half-precision format.
Let
Calculate (A x B) x C by hand, assuming each of the values are stored in the 16-bit half precision format described in Exercise 3.27 (and also described in the text).
Assume 1 guard, 1 round bit, and 1 sticky bit, and round to the nearest even.
First, we calculate AxB = 1.M x 2N
M =_______ (10-bit binary)
N = _________(a negative (decimal) integer)
The product of A and B is an underflow. That is, the result of A*B cannot be represented in the normal 16-bit half precision format.
However, it could be represented as a denorm number. What is the encoding of the this denorm number? (a 4-digit hexadecimal number with uppercase letter digit.)
Solution:--
To prove the (A x B) x C = A x (B x C)
First see
(AxB) x C =
AxB= 1.1100000000 x 1.0001000000 x 2-17
AxB= 1.1101110000 x 2-17
Here M = 1101110000
N = -17 =11101110 (representing Negative number using 2's complement )
(AxB) x C= 1.1101110000 x1.1010011010 x 2-11
(AxB) x C=11.0000100011 x 2-11
Here P = 0000100100 (rounded to even)
Q=-11= 11110101 (representing Negative number using 2's complement )
Final ans 1= 11.000100011 x 2-11
Now check for
Ax(BxC)
BxC= 1.0001000000 x1.1010011010 x 2-2
BxC=1.1100000010 x 2-2
Here M=1100000010
N= -2 =11111110
Ax(BxC) = 1.1100000000 x1.1100000010 x 2-11
Ax(BxC) = 11.0000100011 x 2-11
P = 0000100100 (rounded to even)
Q=-11= 11110101 (representing Negative number using 2's complement )
Final ans 2 = 11.000100011 x 2-11
So final ans 1 = final ans 2
Hence proved