Answers are in blue.
|---------------------------------------------------------------------------------------------------|
| Computer Science Illuminated, Seventh Edition Nell Dale, PhD; John Lewis, PhD |
|-----------------------------------------|
| CHAPTER 2 EXERCISES AND ANSWERS |
For Exercises 1--5, match the following numbers with their definition.
- Number
- Natural number
- Integer number
- Negative number
- Rational number
- A unit of an abstract mathematical system subject to the laws of arithmetic.
A
-
- A natural number, a negative of a natural number, or zero. C
- The number zero and any number obtained by repeatedly adding one to it.
B
-
- An integer or the quotient of two integers (division by zero excluded).
E
-
- A value less than zero, with a sign opposite to its positive counterpart.
D
For Exercises 6--11, match the solution with the problem.
- 10001100
- 10011110
- 1101010
- 1100000
- 1010001
- 1111000
- 1110011 + 11001 (binary addition) A
- 1010101 + 10101 (binary addition) C
- 1111111 + 11111 (binary addition) B
- 1111111 - 111 (binary subtraction) F
- 1100111 - 111 (binary subtraction) D
-
- 1010110 - 101 (binary subtraction) E
For Exercises 12--17, mark the answers true and false as follows:
-
-
- True
- False
- Binary numbers are important in computing because a binary number can be converted into every other base.
-
B错误
-
- Binary numbers can be read off in hexadecimal but not in octal.
B都可以才对
-
- Starting from left to right, every grouping of four binary digits can be read as one hexadecimal digit.
B从右往左读
-
- A byte is made up of six binary digits. B8
- Two hexadecimal digits can be stored in one byte. A 一个16一个4,两个16一个8
- Reading octal digits off as binary produces the same result whether read from right to left or left to right.
A
八进制读成二进制怎么读都是一样的
Exercises 18--47 are problems or short answer questions.
-
- Distinguish between a natural number and a negative number.
A natural number is 0 and any number that can be obtained by repeatedly adding 1 to it. A negative number is less than 0, and opposite in sign to a natural number (although we usually do not consider negative 0).
自然数是0反复加一,
负数小于0,并在自然数上符号相反
-
- Distinguish between a natural number and a rational number. A rational number is an integer or the quotient of integer numbers. (Division by 0 is excluded.) A natural number is 0 and the positive integers. (See also definitions in answer to Exercises 1--5.)
- 有理数是整数的商,
- 自然舒是0和正整数
- Label the following numbers natural, negative, or rational.
- 1.333333
rational
-
-
- -1/3
-
negative, rational
-
-
- 1066
-
natural
-
-
- 2/5
-
rational
-
-
- 6.2
-
rational
-
-
- π (pi)
-
not any listed
-
- If 891 is a number in each of the following bases, how many 1s are there?
- base 10
- If 891 is a number in each of the following bases, how many 1s are there?
891
-
-
- base 8
-
Cannot be a number in base 8
越界
-
-
- base 12
-
1261
-
-
- base 13
-
1470
-
-
- base 16
-
2193
-
- Express 891 as a polynomial in each of the bases in Exercise 21.
- 8 * 102 + 9 * 10 + 1
- Cannot be shown as a polynomial in base 8.
- 8 * 122 + 9 * 12 + 1
- 8 * 132 + 9 * 13 + 1
- 8 * 162 + 9 * 16 + 1
- Convert the following numbers from the base shown to base 10.
- 111 (base 2)
- Express 891 as a polynomial in each of the bases in Exercise 21.
7
-
-
- 777 (base 8)
-
511
-
-
- FEC (base 16) 4076
- 777 (base 16)
-
1911
-
-
- 111 (base 8)
-
73
-
- Explain how base 2 and base 8 are related.
Because 8 is a power of 2, base-8 digits can be read off in binary and three base-2 digits can be read off in octal.
因为8是2的幂,所以可以将八进制数字读取为二进制,并且可以从八进制中读取三个二进制数字。
-
- Explain how base 8 and base 16 are related. 8 and 16 are both powers of two.
- 是的,8和16都是2的幂。其中,8是2的立方,而16是2的四次方。
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | |----------|---------|-----------| | binary | octal | decimal | | 000 | 0 | 0 | | 001 | 1 | 1 | | 010 | 2 | 2 | | |
Expand the table on page 43 to include the numbers from 11 through 16.
|-------|----|----|
| 011 | 3 | 3 |
| 100 | 4 | 4 |
| 101 | 5 | 5 |
| 110 | 6 | 6 |
| 111 | 7 | 7 |
| 1000 | 10 | 8 |
| 1001 | 11 | 9 |
| 1010 | 12 | 10 |
| 1011 | 13 | 11 |
| 1100 | 14 | 12 |
| 1101 | 15 | 13 |
| 1110 | 16 | 14 |
| 1111 | 17 | 15 |
| 10000 | 20 | 16 |
-
- Expand the table in Exercise 26 to include hexadecimal numbers.
|----------|---------|-----------|---------------|
| binary | octal | decimal | hexadecimal |
| 000 | 0 | 0 | 0 |
| 001 | 1 | 1 | 1 |
| 010 | 2 | 2 | 2 |
| 011 | 3 | 3 | 3 |
| 100 | 4 | 4 | 4 |
| 101 | 5 | 5 | 5 |
| 110 | 6 | 6 | 6 |
| 111 | 7 | 7 | 7 |
| 1000 | 10 | 8 | 8 |
| 1001 | 11 | 9 | 9 |
| 1010 | 12 | 10 | A |
| 1011 | 13 | 11 | B |
| 1100 | 14 | 12 | C |
| 1101 | 15 | 13 | D |
| 1110 | 16 | 14 | E |
| 1111 | 17 | 15 | F |
| 10000 | 20 | 16 | 20 |
-
- Convert the following binary numbers to octal.
- 111110110
- Convert the following binary numbers to octal.
766
-
-
- 1000001
-
101
-
-
- 10000010
-
202
-
-
- 1100010
-
142
-
- Convert the following binary numbers to hexadecimal.
- 10101001 A9
- 11100111 E7
- Convert the following binary numbers to hexadecimal.
-
-
- 01101110 6E
- 01111111 7F
- Convert the following hexadecimal numbers to octal.
- A9 251
- E7 347
- 6E 156
- Convert the following octal numbers to hexadecimal.
- 777 1FF
- 605
-
185
-
-
- 443
-
123
-
-
- 521
-
151
-
-
- 1
-
1
-
- Convert the following decimal numbers to octal.
- 901
- Convert the following decimal numbers to octal.
1605
-
-
- 321
-
501
-
-
- 1492
-
2724
-
-
- 1066
-
2052
-
-
- 2001
-
3721
-
- Convert the following decimal numbers to binary.
- 45
- Convert the following decimal numbers to binary.
101101
-
-
- 69
-
1000101
-
-
- 1066
-
10000101010
-
-
- 99
-
1100011
-
-
- 1
-
1
-
- Convert the following decimal numbers to hexadecimal.
- 1066 42A
- 1939
- Convert the following decimal numbers to hexadecimal.
793
-
-
- 1
-
1
-
-
- 998 3E6
- 43 2B
- If you were going to represent numbers in base 18, what symbols might you use to represent the decimal numbers 10 through 17 other than letters?
- 如果你要用
- 18进制表示数字,除了字母之外,你可以使用哪些符号来代表10到17的十进制数字呢?你可以延续十六进制的方法,使用G表示16,H表示17。但任何特殊字符或其他字母表的字符也可以使用,例如,你可以使用#表示16,@表示17。Convert the following decimal numbers to base 18 using the symbols you suggested in Exercise 35.
- 1066
-
354 (answers will vary)
-
-
- 99099
-
#@F9 (answers will vary)
-
-
- 1
-
1 (answers will vary)
-
- Perform the following octal additions.
- 770 + 665
- Perform the following octal additions.
1655
-
-
- 101 + 707
-
1010
-
-
- 202 + 667
-
1071
-
- Perform the following hexadecimal additions.
- 19AB6 + 43 19AF9
- AE9 + F AF8
- 1066 + ABCD BC33
- Perform the following octal subtractions.
- 1066 - 776
- Perform the following hexadecimal additions.
70
-
-
- 1234 - 765
-
247
-
-
- 7766 - 5544
-
2222
-
- Perform the following hexadecimal subtractions.
- ABC - 111 9AB
- 9988 - AB 98DD
- A9F8 - 1492 9566
- Why are binary numbers important in computing?
- Perform the following hexadecimal subtractions.
Data and instructions are represented in binary inside the computer.
二进制数字在计算中为何重要?
计算机内部表示数据和指令时使用二进制。
-
- A byte contains how many bits? 8
-
- How many bytes are there in a 64-bit machine? 8
- Why do microprocessors such as pagers have only 8-bit machines?
Pagers are not general-purpose computers. The programs in pagers are small enough to be represented in 8-bit machines.
寻呼机程序足够小,可以用8位机器表示
-
- Why is important to study how to manipulate fixed-sized numbers?
It is important to understand how to manipulate fixed-sized numbers because numbers are represented in a computer in fixed-sized format.
因为计算机中的数字是以固定大小的格式表示的
-
- How many ones are there in the number AB98 in base 13? ((13 * 13 * 13 * 10) + (13 * 13 * 11) + 13 * 9) + 8) = 23954
- Describe how a bi-quinary number representation works. There are seven lights to represent ten numbers. The first two determine the meaning of the next five. If the first light is on, the next five represent 0, 1, 2, 3, and 4, respectively.
If the second is on, the next five represent 5, 6, 7, 8, and 9, respectively.
描述一下二五进制数的表示方法。有七个灯表示十个数字。前两个灯决定接下来五个的意义。如果第一个灯亮着,接下来的五个分别表示0、1、2、3和4。如果第二个灯亮着,接下来的五个分别表示5、6、7、8和9。