答:
42.下面是一些二进制补码表示的二进制数。请问如何改变他们的正负。 A.01110111 B.11111100 C.01110111 D.11001110
答:We change the sign of the number by applying the two’s complement operation.
a. 01110111 → 10001001 b. 11111100 → 00000100 c. 01110111 → 10001001 d. 11001110 → 00110010
Chapter 4
1.逻辑运算和算术运算有什么区别?
答:Arithmetic operations interpret bit patterns as numbers. Logical operations interpret each bit as a logical value (true or false).
算术运算把位模式理解为数据;逻辑运算的每一位当成逻辑值(真或假)。 2.在二进制补码格式的整数相加中,最左边一列是怎样进位的? 答:The leftmost carry is discarded. 最左边一位被丢弃。
3.n的位分配单元可以等于1吗?为什么? 答:The bit allocation can be 1. In this case, the data type normally represents a logical value.
n的位分配单元可以等于1,在这种情况下,数据类型通常表示逻辑值。 4.解释“溢出”这个词。
答:Overflow happens when the result of an arithmetic operation is outside the range
- 16 -
of allocated values.
“溢出”的发生是指算术运算的结果超出其所能表示的范围。 5.在浮点数的加法运算中,怎样调整指数不同的数的表示方法?
答:The decimal point of the number with the smaller exponent is shifted to the left until the exponents are equal.
在浮点数的加法运算中,增加较小的指数,移位相应的尾数,直到两个数具有相同的指数。
6.一元运算和二元运算有何不同?
答:A unary operation takes a single operand. A binary operation takes two operands. 一元运算只有一个操作数,二元运算有两个操作数。 7.二元逻辑运算有哪些?
答:The common logical binary operations are: AND, OR, and XOR. 8.什么是真值表?
答:A truth table lists all possible input combinations with the corresponding outputs. 真值表就是列出所有可能的输入组合以及相应输出的表。 9.非运算符的作用是什么?
答:The NOT operation inverts logical values (bits): it changes true to false and false to true.
非运算符的作用是对逻辑值(位)取反,它把真变成假,把假变成真。 10.与运算符的结果何时为真?
答:The result of an AND operation is true when both of the operands are true. 11.或运算符的结果何时为真?
答:The result of an OR operation is true when one or both of the operands are true. 12.异或运算符的结果何时为真?
答:The result of an XOR operator is true when the operands are different. 13.说出AND运算符本章讨论的一个重要特性。
答:An important property of the AND operator is that if one of the operands is false, the result is false.
14.说出OR运算符本章讨论的一个重要特性。 答:An important property of the OR operator is that if one of the operands is true, the result is true.
15.说出XOR运算符本章讨论的一个重要特性。
答:An important property of the XOR operator is that if one of the operands is true, the result will be the inverse of the other operand.
16.哪种二元运算可以用来置位?掩码应该用什么位模式? 答:The OR operator can be used to set bits. Set the desired positions in the mask to 1. 或运算可以用来置位。掩码中的1位对第一个输入中的相应的位进行置位,而掩码中的0位使第一个输入中相应的位保持不变。
17. 哪种二元运算可以用来复位?掩码应该用什么位模式?
答:The AND operator can be used to clear bits. Set the desired positions in the mask to 0.
与运算可以用来复位,掩码中的0对第一个输入中相应的位进行复位。掩码中的1位使得第一个输入中相应的位保持不变。
18. 哪种二元运算可以用来反转?掩码应该用什么位模式?
- 17 -
答:The XOR operator can be used to invert bits. Set the desired positions in the mask to 1.
异或运算可以用来对指定位反转,掩码中的1位对第一个输入中的相应的位进行反转,而掩码中的0位使第一个输入中相应的位保持不变。 19.逻辑和算术移位间的区别是什么?
答:The logical shift operation is applied to a pattern that does not represent a signed number. The arithmetic shift operation assumes that the bit pattern is a signed number in two’s complement format.
逻辑移位运算应用于不带符号位的数的模式。算术移位运算假定位模式是用二进制补码格式表示的带符号位的整数。 选择题
20.( )是算术位运算。
A.异或 B.一元非 C.减法 D.以上都是 21.( )是逻辑位运算。
A.异或 B.一元非 C.减法 D.以上都是 22.( )描述整数的方法是计算机存储中最常用的方法。 A.用符号加绝对值 B.二进制反码 C.二进制补码 D.无符号整数
23.二进制补码加法中,如果是最左边一列相加后产生进位,则( )。 A.加到最右边一列 B.加到最左边一列 C.舍弃 D.增加位长度
24.一个8位分配单元,用二进制补码能表示的最小十进制数是( )。 A.―8 B.―127 C.―128 D.―256
25.一个8位分配单元,用二进制补码能表示的最大十进制数是( )。 A.8 B.127 C.128 D.256 26.一个4位分配单元,用二进制补码表示,1加7得到( )。 A.8 B.1 C. ―7 D. ―8 27.一个4位分配单元,用二进制补码表示,5加5得到( )。 A. ―5 B. ―6 C. ―7 D. 10
28.如果在余127码中的指数表示为二进制10000101,那么十进制中的指数是( )。
A.6 B.7 C.8 D.9
29.两个数相加,一个指数值为7,另一个指数值为9,则需要将较小数的小数点( )。
A.左移一位 B.右移一位 C.左移二位 D.右移二位 30.二元运算符( )取两个输入产生一个输出。
A.AND B.OR C.XOR D.前三项 31.一元运算符( )将一个输入取反。
A.AND B.OR C.NOT D.XOR 32.二元运算符( )两个输入为0,输出也为0。
A.AND B.OR C.XOR D.前三项 33.二元运算符( )两个输入为1,输出为0。
A.AND B.OR C.XOR D.前三项
- 18 -
34.二元与运算,只有在输入( )情况下得到输出1。
A.两个0 B.两个1 C.1和0 D.前三项 35.二元或运算,只有在输入( )情况下得到输出0。
A.两个0 B.两个1 C.1和0 D.前三项 36.可以使用一种叫做( )的位模式修改另一个位模式。 A.掩码 B.进位 C.浮点数 D.位
37.要反转一个位模式全部的位,使用全1掩码,对位模式和掩码进行( )运算。
A.AND B.OR C.XOR D.NOT
38.要复位(置0)一个位模式全部的位,对位模式和掩码进行( )运算。 A.AND B.OR C.XOR D.NOT
39.要置位(置1)一个位模式全部的位,对位模式和掩码进行( )运算。 A.AND B.OR C.XOR D.NOT 20. c 21. d 22. c 23. c 24. c 25. b 26. d 27. b 28. a 29. c 30. d 31. c 32. d 33. c 34. b 35. a 36. a 37. c 38. a 39. b 练习题
43.求下列运算结果。 A. NOT[((99)16OR(99)16)] B. (99)16OR[NOT(00)16]
C. [(99)16AND(33)16]OR[(00)16AND(FF)16] D. [(99)16OR(33)16]AND[(00)16OR(FF)16] 解:
44.要将一个位模式的最左4位复位(置0),求掩码和运算。 解: Mask = (00001111)2
Operation: Mask AND (xxxxxxxx)2 = (0000xxxx)2 45.要将一个位模式的最右4位置位(置1),求掩码和运算。 解: Mask = (00001111)2
- 19 -
Operation: Mask OR (xxxxxxxx)2 = (xxxx1111)2
46.将一个位模式的最右3位和最左2位反转,求掩码和运算。 解: Mask: (11000111)2
Operation: Mask XOR (xxxxxxxx)2 = (yyxxxyyy)2,where y is NOT x 47.将一个位模式的最左3位和最右2位复位,求掩码和运算。 解: Mask1= (00011111)2 Mask2 = (00000011)2
Operation: [Mask1 AND (xxxxxxxx)2] OR Mask2 = (000xxx11)2
51.用8位分配单元,首先把下列数转换成二进制补码,然后运算,再把结果转成十进制。
A.19+23 B.19–23 C.–19+23 D.–19–23 解:
52.用16位分配单元,先把下列数转换成二进制补码,然后运算,再结果转成十进制。
A. 161+1023 B.161–1023 C.–161+1023 D.–161–1023 解:
- 20 -