@@ -5,61 +5,62 @@ Do not convert any binary numbers to decimal when solving a question unless the
55The goal of these exercises is for you to gain an intuition for binary numbers. Using tools to solve the problems defeats the point.
66
77Convert the decimal number 14 to binary.
8- Answer:
8+ Answer: 1110
99
1010Convert the binary number 101101 to decimal:
11- Answer:
11+ Answer: 45
1212
1313Which is larger: 1000 or 0111?
14- Answer:
14+ Answer: 1000
1515
1616Which is larger: 00100 or 01011?
17- Answer:
17+ Answer: 01011
1818
1919What is 10101 + 01010?
20- Answer:
20+ Answer: 11111
2121
2222What is 10001 + 10001?
23- Answer:
23+ Answer:100010
2424
2525What's the largest number you can store with 4 bits, if you want to be able to represent the number 0?
26- Answer:
26+ Answer: 1111 = 15 (largest representable number)
27+ Number of possible values including 0 = 16
2728
2829How many bits would you need in order to store the numbers between 0 and 255 inclusive?
29- Answer:
30+ Answer: 8 bits
3031
3132How many bits would you need in order to store the numbers between 0 and 3 inclusive?
32- Answer:
33+ Answer: 2 bits => 00, 01, 10, 11
3334
3435How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
35- Answer:
36+ Answer: 10 bits
3637
3738How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
38- Answer:
39+ Answer: Been a binary it would be 1 followed by 0s => 100, 10000, 10
3940
4041Convert the decimal number 14 to hex.
41- Answer:
42+ Answer:0xE
4243
4344Convert the decimal number 386 to hex.
44- Answer:
45+ Answer: 0x182
4546
4647Convert the hex number 386 to decimal.
47- Answer:
48+ Answer: 902
4849
4950Convert the hex number B to decimal.
50- Answer:
51+ Answer:11
5152
5253If reading the byte 0x21 as a number, what decimal number would it mean?
53- Answer:
54+ Answer:33
5455
5556If reading the byte 0x21 as an ASCII character, what character would it mean?
56- Answer:
57+ Answer:!
5758
5859If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
59- Answer:
60+ Answer: Dark Grey
6061
6162If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
62- Answer:
63+ Answer: Purple (magenta)
6364
6465If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
65- Answer:
66+ Answer: 170 0 255
0 commit comments