@@ -5,61 +5,77 @@ 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+ ```
9+ 14 is equals 8 + 4 + 2 + 0
10+ ```
11+ Answer: 1110
912
1013Convert the binary number 101101 to decimal:
11- Answer:
14+ ```
15+ 32 + 0 + 8 + 4 + 0 + 1
16+ ```
17+ Answer: 45
1218
1319Which is larger: 1000 or 0111?
14- Answer:
20+ Answer: 1000
1521
1622Which is larger: 00100 or 01011?
17- Answer:
23+ Answer: 01011
1824
1925What is 10101 + 01010?
20- Answer:
26+ Answer: 11111
2127
2228What is 10001 + 10001?
23- Answer:
29+ Answer: 100010
2430
2531What's the largest number you can store with 4 bits, if you want to be able to represent the number 0?
26- Answer:
32+ Answer: 15
2733
2834How many bits would you need in order to store the numbers between 0 and 255 inclusive?
29- Answer:
35+ Answer: 7
3036
3137How many bits would you need in order to store the numbers between 0 and 3 inclusive?
32- Answer:
38+ Answer: 2
3339
3440How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
35- Answer:
41+ Answer: 9
3642
3743How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
38- Answer:
44+ Answer: If the number have only one '1' digit at the start and other digits are 0 - the number is a power of two
3945
4046Convert the decimal number 14 to hex.
41- Answer:
47+ Answer: F
4248
4349Convert the decimal number 386 to hex.
44- Answer:
50+ ```
51+ 386 / 16 = 24 reminder 2
52+ 24 / 16 = 1 remider 8
53+ ```
54+ Answer: 182
4555
4656Convert the hex number 386 to decimal.
47- Answer:
57+ ```
58+ 3 * 16^2 = 3 * 256 = 768
59+ 8 * 16^1 = 128
60+ 6 * 16^0 = 6
61+ 768 + 128 + 6 = 902
62+ ```
63+ Answer: 902
4864
4965Convert the hex number B to decimal.
50- Answer:
66+ Answer: 11
5167
5268If reading the byte 0x21 as a number, what decimal number would it mean?
53- Answer:
69+ Answer: 33
5470
5571If reading the byte 0x21 as an ASCII character, what character would it mean?
56- Answer:
72+ Answer: !
5773
5874If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
59- Answer:
75+ Answer: Gray colour with light intensity equals 33
6076
6177If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
62- Answer:
78+ Answer: Shade of purple, since this number represent the mix of red an blue colour, without green
6379
6480If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
65- Answer:
81+ Answer: 170 , 0, 255
0 commit comments