Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 12^4 - 1 = 15 | A20 <= 2^4 - 1 is False | |
| 22^5 - 1 = 31 | BForgot to subtract 1. Counting starts at 0, so the largest 4-bit number is 2^4 - 1 = 15. | |
| 3To test if a number fits in a bit length, compare it with the largest value for that length | C4 bits can hold at most 15, so 20 is too big for 4 bits | |
| 4Choose the smallest bit length n whose largest value is at least your number | Dn = 5 because 2^5 - 1 >= 25 | |
| 5Largest 4-bit number = 2^4 = 16 | E5 bits can hold up to 31, so 25 fits in 5 bits | |
| 631 needs 6 bits because 31 is not bigger than 2^5 - 1 | F31 equals the largest 5-bit value (2^5 - 1 = 31), so it fits in 5 bits. A number only needs more bits if it is bigger than the maximum. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
2^n - 1 >= number — Find the smallest number of bits n whose largest value, 2^n - 1, is at least your number. Example: 20 is too big for 4 bits (max 15), so it needs 5 bits (max 31).4 bits: 2^4 - 1 = 152^5 - 1 = 31, which is at least 25Is 2^5 - 1 >= 25? Yes, so 5 bits is enoughn = 1
WHILE 2^n - 1 < 20:
n = n + 19: 2^3 - 1 = 7 is too small, so use 2^4 - 1