Exam practice
Every question from the end of every unit, with hints and answers to open. After you check an answer, mark how you did, and come back to the ones you didn’t get.
14 questions
Unit 2 · Number System
2. Answer these questions
What is a number system?
Answer
A number system is a way of writing numbers: a set of symbols (digits) and rules for using them to express numbers and to do calculations with them. Each number system has its own base, the number of digits it uses. For example, the decimal number system uses the ten digits 0 to 9, and the binary number system, which computers use, uses 0 and 1.
Define the base or radix of a number system.
Answer
The base or radix of a number system is the total number of different digits (symbols) it uses. It also decides the place values: each position is worth the base times the position to its right. Decimal has base 10 (0–9), binary base 2 (0, 1), octal base 8 (0–7) and hexadecimal base 16 (0–9, A–F). The base is written as a small number after a number, as in (101)₂.
List the different types of number systems.
Answer
| Number system | Base | Digits used |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0 to 7 |
| Decimal | 10 | 0 to 9 |
| Hexadecimal | 16 | 0 to 9 and A to F |
What is the hexadecimal number system? Write the symbols used in it.
Answer
The hexadecimal number system is the base-16 number system. It uses sixteen symbols: the ten digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and the six letters A, B, C, D, E, F, which stand for 10, 11, 12, 13, 14 and 15. Its place values are powers of 16 (1, 16, 256, …). One hex digit stands for exactly four bits, so programmers use hex as a short way of writing binary, for example in web colors such as #FF8800, memory addresses and MAC addresses.
3. Calculate the following as indicated
Perform the following binary additions:
- i.(11110)₂ + (1001)₂
- ii.(1011)₂ + (1001)₂
- iii.(101011)₂ + (11011)₂
- iv.(1010)₂ + (110)₂
- v.(101001)₂ + (1110)₂
- vi.(100001)₂ + (100011)₂
- vii.(100111)₂ + (11010)₂
- viii.(110001)₂ + (100101)₂
Answer
Each sum is set out in columns, with the carries above and the decimal values on the right as a check.
i. (11110)₂ + (1001)₂ = (100111)₂
carry 1 1 1 1 1 1 0 30 + 1 0 0 1 9 ----------- 1 0 0 1 1 1 39ii. (1011)₂ + (1001)₂ = (10100)₂
carry 1 1 1 1 0 1 1 11 + 1 0 0 1 9 --------- 1 0 1 0 0 20iii. (101011)₂ + (11011)₂ = (1000110)₂
carry 1 1 1 1 1 1 0 1 0 1 1 43 + 1 1 0 1 1 27 ------------- 1 0 0 0 1 1 0 70iv. (1010)₂ + (110)₂ = (10000)₂
carry 1 1 1 1 0 1 0 10 + 1 1 0 6 --------- 1 0 0 0 0 16v. (101001)₂ + (1110)₂ = (110111)₂
carry 1 1 0 1 0 0 1 41 + 1 1 1 0 14 ----------- 1 1 0 1 1 1 55vi. (100001)₂ + (100011)₂ = (1000100)₂
carry 1 1 1 1 0 0 0 0 1 33 + 1 0 0 0 1 1 35 ------------- 1 0 0 0 1 0 0 68vii. (100111)₂ + (11010)₂ = (1000001)₂
carry 1 1 1 1 1 1 0 0 1 1 1 39 + 1 1 0 1 0 26 ------------- 1 0 0 0 0 0 1 65viii. (110001)₂ + (100101)₂ = (1010110)₂
carry 1 1 1 1 0 0 0 1 49 + 1 0 0 1 0 1 37 ------------- 1 0 1 0 1 1 0 86Perform the following binary subtractions:
- i.(1100)₂ − (1001)₂
- ii.(1001)₂ − (110)₂
- iii.(11101)₂ − (1010)₂
- iv.(101100)₂ − (10011)₂
- v.(11111)₂ − (10110)₂
- vi.(110011)₂ − (10100)₂
- vii.(100100)₂ − (1110)₂
- viii.(1000001)₂ − (10101)₂
Answer
Each is set out in columns with the decimal values on the right, then the borrows, then a check by adding.
i. (1100)₂ − (1001)₂ = (11)₂
1 1 0 0 12 − 1 0 0 1 9 ------- 1 1 3Borrowing: the 1s column borrows from the 4s (the 0 in the 2s becomes 1). Check: 11 + 1001 = 1100 ✓
ii. (1001)₂ − (110)₂ = (11)₂
1 0 0 1 9 − 1 1 0 6 ------- 1 1 3Borrowing: the 2s column borrows from the 8s (the 0 in the 4s becomes 1). Check: 11 + 110 = 1001 ✓
iii. (11101)₂ − (1010)₂ = (10011)₂
1 1 1 0 1 29 − 1 0 1 0 10 --------- 1 0 0 1 1 19Borrowing: the 2s column borrows from the 4s. Check: 10011 + 1010 = 11101 ✓
iv. (101100)₂ − (10011)₂ = (11001)₂
1 0 1 1 0 0 44 − 1 0 0 1 1 19 ----------- 1 1 0 0 1 25Borrowing: the 1s column borrows from the 4s (the 0 in the 2s becomes 1); the 16s column borrows from the 32s. Check: 11001 + 10011 = 101100 ✓
v. (11111)₂ − (10110)₂ = (1001)₂
1 1 1 1 1 31 − 1 0 1 1 0 22 --------- 1 0 0 1 9No column needs to borrow. Check: 1001 + 10110 = 11111 ✓
vi. (110011)₂ − (10100)₂ = (11111)₂
1 1 0 0 1 1 51 − 1 0 1 0 0 20 ----------- 1 1 1 1 1 31Borrowing: the 4s column borrows from the 16s (the 0 in the 8s becomes 1); the 16s column borrows from the 32s. Check: 11111 + 10100 = 110011 ✓
vii. (100100)₂ − (1110)₂ = (10110)₂
1 0 0 1 0 0 36 − 1 1 1 0 14 ----------- 1 0 1 1 0 22Borrowing: the 2s column borrows from the 4s; the 4s column borrows from the 32s (the 0s in the 8s and 16s become 1s). Check: 10110 + 1110 = 100100 ✓
viii. (1000001)₂ − (10101)₂ = (101100)₂
1 0 0 0 0 0 1 65 − 1 0 1 0 1 21 ------------- 1 0 1 1 0 0 44Borrowing: the 4s column borrows from the 64s (the 0s in the 8s, 16s and 32s become 1s). Check: 101100 + 10101 = 1000001 ✓
4. Convert the given numbers as indicated
Decimal to binary:
i. (56)₁₀ ii. (78)₁₀ iii. (123)₁₀ iv. (345)₁₀ v. (540)₁₀ vi. (572)₁₀ vii. (546)₁₀ viii. (1098)₁₀ ix. (2103)₁₀ x. (445)₁₀
Answer
Divide by 2 again and again (“r” is the remainder), then read the remainders from the bottom up.
- i.(56)₁₀: 56 ÷ 2 = 28 r 0; 28 ÷ 2 = 14 r 0; 14 ÷ 2 = 7 r 0; 7 ÷ 2 = 3 r 1; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (111000)₂
- ii.(78)₁₀: 78 ÷ 2 = 39 r 0; 39 ÷ 2 = 19 r 1; 19 ÷ 2 = 9 r 1; 9 ÷ 2 = 4 r 1; 4 ÷ 2 = 2 r 0; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (1001110)₂
- iii.(123)₁₀: 123 ÷ 2 = 61 r 1; 61 ÷ 2 = 30 r 1; 30 ÷ 2 = 15 r 0; 15 ÷ 2 = 7 r 1; 7 ÷ 2 = 3 r 1; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (1111011)₂
- iv.(345)₁₀: 345 ÷ 2 = 172 r 1; 172 ÷ 2 = 86 r 0; 86 ÷ 2 = 43 r 0; 43 ÷ 2 = 21 r 1; 21 ÷ 2 = 10 r 1; 10 ÷ 2 = 5 r 0; 5 ÷ 2 = 2 r 1; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (101011001)₂
- v.(540)₁₀: 540 ÷ 2 = 270 r 0; 270 ÷ 2 = 135 r 0; 135 ÷ 2 = 67 r 1; 67 ÷ 2 = 33 r 1; 33 ÷ 2 = 16 r 1; 16 ÷ 2 = 8 r 0; 8 ÷ 2 = 4 r 0; 4 ÷ 2 = 2 r 0; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (1000011100)₂
- vi.(572)₁₀: 572 ÷ 2 = 286 r 0; 286 ÷ 2 = 143 r 0; 143 ÷ 2 = 71 r 1; 71 ÷ 2 = 35 r 1; 35 ÷ 2 = 17 r 1; 17 ÷ 2 = 8 r 1; 8 ÷ 2 = 4 r 0; 4 ÷ 2 = 2 r 0; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (1000111100)₂
- vii.(546)₁₀: 546 ÷ 2 = 273 r 0; 273 ÷ 2 = 136 r 1; 136 ÷ 2 = 68 r 0; 68 ÷ 2 = 34 r 0; 34 ÷ 2 = 17 r 0; 17 ÷ 2 = 8 r 1; 8 ÷ 2 = 4 r 0; 4 ÷ 2 = 2 r 0; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (1000100010)₂
- viii.(1098)₁₀: 1098 ÷ 2 = 549 r 0; 549 ÷ 2 = 274 r 1; 274 ÷ 2 = 137 r 0; 137 ÷ 2 = 68 r 1; 68 ÷ 2 = 34 r 0; 34 ÷ 2 = 17 r 0; 17 ÷ 2 = 8 r 1; 8 ÷ 2 = 4 r 0; 4 ÷ 2 = 2 r 0; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (10001001010)₂
- ix.(2103)₁₀: 2103 ÷ 2 = 1051 r 1; 1051 ÷ 2 = 525 r 1; 525 ÷ 2 = 262 r 1; 262 ÷ 2 = 131 r 0; 131 ÷ 2 = 65 r 1; 65 ÷ 2 = 32 r 1; 32 ÷ 2 = 16 r 0; 16 ÷ 2 = 8 r 0; 8 ÷ 2 = 4 r 0; 4 ÷ 2 = 2 r 0; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (100000110111)₂
- x.(445)₁₀: 445 ÷ 2 = 222 r 1; 222 ÷ 2 = 111 r 0; 111 ÷ 2 = 55 r 1; 55 ÷ 2 = 27 r 1; 27 ÷ 2 = 13 r 1; 13 ÷ 2 = 6 r 1; 6 ÷ 2 = 3 r 0; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1. Remainders from the bottom up: (110111101)₂
Binary to decimal:
i. (1101)₂ ii. (1010)₂ iii. (10010)₂ iv. (10110)₂ v. (101001)₂ vi. (11100111)₂ vii. (111100)₂ viii. (10010011)₂ ix. (1011100)₂ x. (100110)₂
Answer
Multiply each digit by its place value (a power of 2) and add.
- i.(1101)₂ = 1 × 2³ + 1 × 2² + 0 × 2¹ + 1 × 2⁰ = 8 + 4 + 0 + 1 = 13
- ii.(1010)₂ = 1 × 2³ + 0 × 2² + 1 × 2¹ + 0 × 2⁰ = 8 + 0 + 2 + 0 = 10
- iii.(10010)₂ = 1 × 2⁴ + 0 × 2³ + 0 × 2² + 1 × 2¹ + 0 × 2⁰ = 16 + 0 + 0 + 2 + 0 = 18
- iv.(10110)₂ = 1 × 2⁴ + 0 × 2³ + 1 × 2² + 1 × 2¹ + 0 × 2⁰ = 16 + 0 + 4 + 2 + 0 = 22
- v.(101001)₂ = 1 × 2⁵ + 0 × 2⁴ + 1 × 2³ + 0 × 2² + 0 × 2¹ + 1 × 2⁰ = 32 + 0 + 8 + 0 + 0 + 1 = 41
- vi.(11100111)₂ = 1 × 2⁷ + 1 × 2⁶ + 1 × 2⁵ + 0 × 2⁴ + 0 × 2³ + 1 × 2² + 1 × 2¹ + 1 × 2⁰ = 128 + 64 + 32 + 0 + 0 + 4 + 2 + 1 = 231
- vii.(111100)₂ = 1 × 2⁵ + 1 × 2⁴ + 1 × 2³ + 1 × 2² + 0 × 2¹ + 0 × 2⁰ = 32 + 16 + 8 + 4 + 0 + 0 = 60
- viii.(10010011)₂ = 1 × 2⁷ + 0 × 2⁶ + 0 × 2⁵ + 1 × 2⁴ + 0 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰ = 128 + 0 + 0 + 16 + 0 + 0 + 2 + 1 = 147
- ix.(1011100)₂ = 1 × 2⁶ + 0 × 2⁵ + 1 × 2⁴ + 1 × 2³ + 1 × 2² + 0 × 2¹ + 0 × 2⁰ = 64 + 0 + 16 + 8 + 4 + 0 + 0 = 92
- x.(100110)₂ = 1 × 2⁵ + 0 × 2⁴ + 0 × 2³ + 1 × 2² + 1 × 2¹ + 0 × 2⁰ = 32 + 0 + 0 + 4 + 2 + 0 = 38
Decimal to octal:
i. (69)₁₀ ii. (216)₁₀ iii. (767)₁₀ iv. (79)₁₀ v. (443)₁₀ vi. (413)₁₀ vii. (765)₁₀ viii. (1334)₁₀ ix. (1825)₁₀ x. (2783)₁₀
Answer
Divide by 8 again and again, then read the remainders from the bottom up.
- i.(69)₁₀: 69 ÷ 8 = 8 r 5; 8 ÷ 8 = 1 r 0; 1 ÷ 8 = 0 r 1. Remainders from the bottom up: (105)₈
- ii.(216)₁₀: 216 ÷ 8 = 27 r 0; 27 ÷ 8 = 3 r 3; 3 ÷ 8 = 0 r 3. Remainders from the bottom up: (330)₈
- iii.(767)₁₀: 767 ÷ 8 = 95 r 7; 95 ÷ 8 = 11 r 7; 11 ÷ 8 = 1 r 3; 1 ÷ 8 = 0 r 1. Remainders from the bottom up: (1377)₈
- iv.(79)₁₀: 79 ÷ 8 = 9 r 7; 9 ÷ 8 = 1 r 1; 1 ÷ 8 = 0 r 1. Remainders from the bottom up: (117)₈
- v.(443)₁₀: 443 ÷ 8 = 55 r 3; 55 ÷ 8 = 6 r 7; 6 ÷ 8 = 0 r 6. Remainders from the bottom up: (673)₈
- vi.(413)₁₀: 413 ÷ 8 = 51 r 5; 51 ÷ 8 = 6 r 3; 6 ÷ 8 = 0 r 6. Remainders from the bottom up: (635)₈
- vii.(765)₁₀: 765 ÷ 8 = 95 r 5; 95 ÷ 8 = 11 r 7; 11 ÷ 8 = 1 r 3; 1 ÷ 8 = 0 r 1. Remainders from the bottom up: (1375)₈
- viii.(1334)₁₀: 1334 ÷ 8 = 166 r 6; 166 ÷ 8 = 20 r 6; 20 ÷ 8 = 2 r 4; 2 ÷ 8 = 0 r 2. Remainders from the bottom up: (2466)₈
- ix.(1825)₁₀: 1825 ÷ 8 = 228 r 1; 228 ÷ 8 = 28 r 4; 28 ÷ 8 = 3 r 4; 3 ÷ 8 = 0 r 3. Remainders from the bottom up: (3441)₈
- x.(2783)₁₀: 2783 ÷ 8 = 347 r 7; 347 ÷ 8 = 43 r 3; 43 ÷ 8 = 5 r 3; 5 ÷ 8 = 0 r 5. Remainders from the bottom up: (5337)₈
Octal to decimal:
i. (124)₈ ii. (242)₈ iii. (333)₈ iv. (763)₈ v. (103)₈ vi. (451)₈ vii. (3401)₈ viii. (1045)₈ ix. (437)₈ x. (611)₈
The textbook prints ix. as (438)₈, but 8 is not an octal digit, so the book’s number doesn’t work; (437)₈ is used here.
Answer
Multiply each digit by its place value (a power of 8) and add.
- i.(124)₈ = 1 × 8² + 2 × 8¹ + 4 × 8⁰ = 64 + 16 + 4 = 84
- ii.(242)₈ = 2 × 8² + 4 × 8¹ + 2 × 8⁰ = 128 + 32 + 2 = 162
- iii.(333)₈ = 3 × 8² + 3 × 8¹ + 3 × 8⁰ = 192 + 24 + 3 = 219
- iv.(763)₈ = 7 × 8² + 6 × 8¹ + 3 × 8⁰ = 448 + 48 + 3 = 499
- v.(103)₈ = 1 × 8² + 0 × 8¹ + 3 × 8⁰ = 64 + 0 + 3 = 67
- vi.(451)₈ = 4 × 8² + 5 × 8¹ + 1 × 8⁰ = 256 + 40 + 1 = 297
- vii.(3401)₈ = 3 × 8³ + 4 × 8² + 0 × 8¹ + 1 × 8⁰ = 1,536 + 256 + 0 + 1 = 1,793
- viii.(1045)₈ = 1 × 8³ + 0 × 8² + 4 × 8¹ + 5 × 8⁰ = 512 + 0 + 32 + 5 = 549
- ix.(437)₈ = 4 × 8² + 3 × 8¹ + 7 × 8⁰ = 256 + 24 + 7 = 287
- x.(611)₈ = 6 × 8² + 1 × 8¹ + 1 × 8⁰ = 384 + 8 + 1 = 393
Decimal to hexadecimal:
i. (55)₁₀ ii. (540)₁₀ iii. (225)₁₀ iv. (880)₁₀ v. (2046)₁₀ vi. (2024)₁₀ vii. (6678)₁₀
Answer
Divide by 16 again and again, write a remainder of 10 to 15 as A to F, and read the remainders from the bottom up.
- i.(55)₁₀: 55 ÷ 16 = 3 r 7; 3 ÷ 16 = 0 r 3. Remainders from the bottom up: (37)₁₆
- ii.(540)₁₀: 540 ÷ 16 = 33 r 12 = C; 33 ÷ 16 = 2 r 1; 2 ÷ 16 = 0 r 2. Remainders from the bottom up: (21C)₁₆
- iii.(225)₁₀: 225 ÷ 16 = 14 r 1; 14 ÷ 16 = 0 r 14 = E. Remainders from the bottom up: (E1)₁₆
- iv.(880)₁₀: 880 ÷ 16 = 55 r 0; 55 ÷ 16 = 3 r 7; 3 ÷ 16 = 0 r 3. Remainders from the bottom up: (370)₁₆
- v.(2046)₁₀: 2046 ÷ 16 = 127 r 14 = E; 127 ÷ 16 = 7 r 15 = F; 7 ÷ 16 = 0 r 7. Remainders from the bottom up: (7FE)₁₆
- vi.(2024)₁₀: 2024 ÷ 16 = 126 r 8; 126 ÷ 16 = 7 r 14 = E; 7 ÷ 16 = 0 r 7. Remainders from the bottom up: (7E8)₁₆
- vii.(6678)₁₀: 6678 ÷ 16 = 417 r 6; 417 ÷ 16 = 26 r 1; 26 ÷ 16 = 1 r 10 = A; 1 ÷ 16 = 0 r 1. Remainders from the bottom up: (1A16)₁₆
Hexadecimal to decimal:
i. (56)₁₆ ii. (67)₁₆ iii. (558)₁₆ iv. (B74)₁₆ v. (20D3)₁₆ vi. (DEF)₁₆ vii. (6E3)₁₆ viii. (63F)₁₆
Answer
Multiply each digit by its place value (a power of 16; A = 10 … F = 15) and add.
- i.(56)₁₆ = 5 × 16¹ + 6 × 16⁰ = 80 + 6 = 86
- ii.(67)₁₆ = 6 × 16¹ + 7 × 16⁰ = 96 + 7 = 103
- iii.(558)₁₆ = 5 × 16² + 5 × 16¹ + 8 × 16⁰ = 1,280 + 80 + 8 = 1,368
- iv.(B74)₁₆ = 11 × 16² + 7 × 16¹ + 4 × 16⁰ = 2,816 + 112 + 4 = 2,932
- v.(20D3)₁₆ = 2 × 16³ + 0 × 16² + 13 × 16¹ + 3 × 16⁰ = 8,192 + 0 + 208 + 3 = 8,403
- vi.(DEF)₁₆ = 13 × 16² + 14 × 16¹ + 15 × 16⁰ = 3,328 + 224 + 15 = 3,567
- vii.(6E3)₁₆ = 6 × 16² + 14 × 16¹ + 3 × 16⁰ = 1,536 + 224 + 3 = 1,763
- viii.(63F)₁₆ = 6 × 16² + 3 × 16¹ + 15 × 16⁰ = 1,536 + 48 + 15 = 1,599
Binary to hexadecimal:
i. (1000110)₂ ii. (11001)₂ iii. (1111000)₂ iv. (11110000111)₂ v. (101010110)₂ vi. (1110010110)₂ vii. (11011001)₂ viii. (1001100)₂
Answer
Group the bits in fours from the right, filling the left group with 0s, and write each group as one hex digit. The decimal value is given as a check.
- i.(1000110)₂: 0100 0110 = 0100 → 4, 0110 → 6. (46)₁₆ (both are 70)
- ii.(11001)₂: 0001 1001 = 0001 → 1, 1001 → 9. (19)₁₆ (both are 25)
- iii.(1111000)₂: 0111 1000 = 0111 → 7, 1000 → 8. (78)₁₆ (both are 120)
- iv.(11110000111)₂: 0111 1000 0111 = 0111 → 7, 1000 → 8, 0111 → 7. (787)₁₆ (both are 1,927)
- v.(101010110)₂: 0001 0101 0110 = 0001 → 1, 0101 → 5, 0110 → 6. (156)₁₆ (both are 342)
- vi.(1110010110)₂: 0011 1001 0110 = 0011 → 3, 1001 → 9, 0110 → 6. (396)₁₆ (both are 918)
- vii.(11011001)₂: 1101 1001 = 1101 → D, 1001 → 9. (D9)₁₆ (both are 217)
- viii.(1001100)₂: 0100 1100 = 0100 → 4, 1100 → C. (4C)₁₆ (both are 76)
Hexadecimal to binary:
i. (D4)₁₆ ii. (643)₁₆ iii. (189)₁₆ iv. (2BF)₁₆ v. (A9F)₁₆ vi. (FACE)₁₆ vii. (FB4)₁₆ viii. (1B2)₁₆
Answer
Write each hex digit as four bits; the 0s at the very front may be dropped.
- i.(D4)₁₆: D = 1101, 4 = 0100. (11010100)₂
- ii.(643)₁₆: 6 = 0110, 4 = 0100, 3 = 0011. (11001000011)₂
- iii.(189)₁₆: 1 = 0001, 8 = 1000, 9 = 1001. (110001001)₂
- iv.(2BF)₁₆: 2 = 0010, B = 1011, F = 1111. (1010111111)₂
- v.(A9F)₁₆: A = 1010, 9 = 1001, F = 1111. (101010011111)₂
- vi.(FACE)₁₆: F = 1111, A = 1010, C = 1100, E = 1110. (1111101011001110)₂
- vii.(FB4)₁₆: F = 1111, B = 1011, 4 = 0100. (111110110100)₂
- viii.(1B2)₁₆: 1 = 0001, B = 1011, 2 = 0010. (110110010)₂
