@@ -5,62 +5,61 @@ 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: 1110
8+ Answer:
99
1010Convert the binary number 101101 to decimal:
11- Answer: 32+8+4+1 = 45
11+ Answer:
1212
1313Which is larger: 1000 or 0111?
14- Answer: 1000
14+ Answer:
1515
1616Which is larger: 00100 or 01011?
17- Answer: 01011
17+ Answer:
1818
1919What is 10101 + 01010?
20- Answer: 11111
20+ Answer:
2121
2222What is 10001 + 10001?
23- Answer: 100010
23+ Answer:
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: 15
26+ Answer:
2727
2828How many bits would you need in order to store the numbers between 0 and 255 inclusive?
29- Answer: 2^8 = 255 so 8 bits
29+ Answer:
3030
3131How many bits would you need in order to store the numbers between 0 and 3 inclusive?
32- Answer: 2^2=4 2 bits
32+ Answer:
33+
3334How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
34- Answer: 2^10 = 1024 so 10 bits
35+ Answer:
3536
3637How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
37- Answer: It's a power of 2 when it had only one 1
38+ Answer:
3839
3940Convert the decimal number 14 to hex.
40- Answer: E
41+ Answer:
4142
4243Convert the decimal number 386 to hex.
43- Answer: 182
44+ Answer:
4445
4546Convert the hex number 386 to decimal.
46- Answer: 3 * 16^2 + 8 * 16^1 + 6 * 16^0 = 902
47+ Answer:
4748
4849Convert the hex number B to decimal.
49- Answer: 11
50+ Answer:
5051
5152If reading the byte 0x21 as a number, what decimal number would it mean?
52- Answer: 2×16^1 + 1×16^0 33
53+ Answer:
5354
5455If reading the byte 0x21 as an ASCII character, what character would it mean?
55- Answer: Should be converted to Decimal then ASCII code 33 : !
56+ Answer:
5657
5758If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
58- Answer: A very dark grey (almost black), because 0 = black, 255 = white, and 33 is very low in (0-255)
59+ Answer:
5960
6061If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
61- Answer: Purple , because no green, and full blue
62+ Answer:
6263
6364If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
64- Answer: AA = 170
65- 00 = 0
66- FF = 255
65+ Answer:
0 commit comments