第4章部分习题参考答案
【4-4】已知X和Y,试用它们的变形补码计算出X + Y,并指出结果是否溢出
(3)X = -0.10110,Y = -0.00001 解:[X]补 = 1.01010 [Y]补 = 1.11111
1 1 . 0 1 0 1 0 + 1 1 . 1 1 1 1 1 1 1 . 0 1 0 0 1 无溢出,X+Y = -0.10111
【4-5】已知X和Y,试用它们的变形补码计算出X - Y,并指出结果是否溢出
(3)X = 0.11011,Y = -0.10011 解:[X]补 = 0.11011 [-Y]补 = 0.10011
0 0 . 1 1 0 1 1 + 0 0 . 1 0 0 1 1 0 1 . 0 1 1 1 0 结果正溢
【4-8】分别用原码乘法和补码乘法计算X * Y (1)X = 0.11011,Y = -0.11111 法一:原码一位乘算法
解:|X| = 0.11011→B |Y| = 0.11111→C 0→A
A C 说明
0 0. 0 0 0 0 0 1 1 1 1 1 +0 0. 1 1 0 1 1 C5 = 1, +|X| 0 0. 1 1 0 1 1 0 0. 0 1 1 0 1 1 1 1 1 1 部分积右移一位→ +0 0. 1 1 0 1 1 C5 = 1, +|X| 0 1. 0 1 0 0 0 0 0. 1 0 1 0 0 0 1 1 1 1 部分积右移一位→ +0 0. 1 1 0 1 1 C5 = 1, +|X| 0 1. 0 1 1 1 1 0 0. 1 0 1 1 1 1 0 1 1 1 部分积右移一位→ +0 0. 1 1 0 1 1 C5 = 1, +|X| 0 1. 1 0 0 1 0 0 0. 1 1 0 0 1 0 1 0 1 1 部分积右移一位→ +0 0. 1 1 0 1 1 C5 = 1, +|X| 0 1. 1 0 1 0 0 0 0. 1 1 0 1 0 0 0 1 0 1 部分积右移一位→ |X * Y| = 0.1101000101
Ps = Xs ⊕ Ys = 0 ⊕ 1 = 1 X*Y = -0.1101000101
法二:补码一位乘算法
解:[X]补 = 0.11011→B [Y]补 = 1.00001→C [-X]补 = 1.00101 0→A
A C +1 1. 0 0 1 0 1 0 0. 0 0 0 0 0 附加
1 1. 0 0 1 0 1 1 0 0 0 0 1 0 →
1 1. 1 0 0 1 0 1 1 0 0 0 0 1 +0 0. 1 1 0 1 1 0 0. 0 1 1 0 1 →
0 0. 0 0 1 1 0 1 1 1 0 0 0 0 +0 0. 0 0 0 0 0 0 0. 0 0 1 1 0 →
0 0. 0 0 0 1 1 0 1 1 1 0 0 0 +0 0. 0 0 0 0 0 0 0. 0 0 0 1 1 →
0 0. 0 0 0 0 1 1 0 1 1 1 0 0 +0 0. 0 0 0 0 0 0 0. 0 0 0 0 1 →
0 0. 0 0 0 0 0 1 1 0 1 1 1 0 +1 1. 0 0 1 0 1 1 1. 0 0 1 0 1 [X*Y]补= 11.0010111011
X*Y = -0.1101000101
说明
C4C5 = 10 -|X| 部分积右移一位C4C5 = 01 +|X| 部分积右移一位C4C5 = 00 +0 部分积右移一位C4C5 = 00 +0 部分积右移一位C4C5 = 00 +0 部分积右移一位C4C5 = 10 -|X|