@@ -6,60 +6,80 @@ The goal of these exercises is for you to gain an intuition for binary numbers.
66
77Convert the decimal number 14 to binary.
88Answer:
9+ 1110
910
1011Convert the binary number 101101 to decimal:
1112Answer:
13+ 45
1214
1315Which is larger: 1000 or 0111?
1416Answer:
17+ 1000
1518
1619Which is larger: 00100 or 01011?
1720Answer:
21+ 01011
1822
1923What is 10101 + 01010?
2024Answer:
25+ 11111
2126
2227What is 10001 + 10001?
2328Answer:
29+ 100010
2430
2531What's the largest number you can store with 4 bits, if you want to be able to represent the number 0?
2632Answer:
33+ 15
2734
2835How many bits would you need in order to store the numbers between 0 and 255 inclusive?
2936Answer:
37+ 8 bits
3038
3139How many bits would you need in order to store the numbers between 0 and 3 inclusive?
3240Answer:
41+ 2 bits
3342
3443How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
3544Answer:
45+ 10 bits
3646
3747How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
3848Answer:
49+ A number that is a power of two in binary has exactly one bit set to 1.
3950
4051Convert the decimal number 14 to hex.
4152Answer:
53+ E
4254
4355Convert the decimal number 386 to hex.
4456Answer:
57+ 182
4558
4659Convert the hex number 386 to decimal.
4760Answer:
61+ 902
4862
4963Convert the hex number B to decimal.
5064Answer:
65+ 11
5166
5267If reading the byte 0x21 as a number, what decimal number would it mean?
5368Answer:
69+ 33
5470
5571If reading the byte 0x21 as an ASCII character, what character would it mean?
5672Answer:
73+ !
5774
5875If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
5976Answer:
77+ dark grey
6078
6179If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
6280Answer:
81+ purple
6382
6483If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
6584Answer:
85+ 170, 0, 255
0 commit comments