@@ -5,61 +5,90 @@ 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
9+
10+ 2^3 - 8 - (8<=14) - 1
11+ 2^2 - 4 - (4<=6) - 1
12+ 2^1 - 2 - (2<=2) - 1
13+ 2^0 - 1 - (0<=1) - 0
914
1015Convert the binary number 101101 to decimal:
11- Answer:
16+ Answer:45
17+ 1 - 32
18+ 0 - 16
19+ 1 = 8
20+ 1 - 4
21+ 0 - 2
22+ 1 - 1
23+
24+ 45
1225
1326Which is larger: 1000 or 0111?
14- Answer:
27+ Answer: 1000 > 0111
1528
1629Which is larger: 00100 or 01011?
17- Answer:
30+ Answer: 00100 < 01011
1831
1932What is 10101 + 01010?
20- Answer:
33+ Answer: 11111
2134
2235What is 10001 + 10001?
23- Answer:
36+ Answer:100010
2437
2538What's the largest number you can store with 4 bits, if you want to be able to represent the number 0?
26- Answer:
39+ Answer: 15
2740
2841How many bits would you need in order to store the numbers between 0 and 255 inclusive?
29- Answer:
42+ Answer: 2^8, 8 bits
3043
3144How many bits would you need in order to store the numbers between 0 and 3 inclusive?
32- Answer:
45+ Answer: 2 bit
3346
3447How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
35- Answer:
48+ Answer: 2^10, 10 bits
3649
3750How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
38- Answer:
51+ Answer: every number from range has just one of 1 bit and all the rest are zeros
3952
4053Convert the decimal number 14 to hex.
41- Answer:
54+ Answer: E Took from table.
4255
4356Convert the decimal number 386 to hex.
44- Answer:
57+ Answer: 182
58+
59+ 386/16 = 24 (rem 2)
60+ 24/16 = 1 (rem 8)
61+ 1/16 = 0 (rem 1)
4562
4663Convert the hex number 386 to decimal.
47- Answer:
64+ Answer: 902
65+
66+ 3 8 6
67+ 16^2 16^1 16^0
68+ 3* 256, 8* 16, 6\* 1
69+ 768 + 128 + 6
70+ 902
4871
4972Convert the hex number B to decimal.
50- Answer:
73+ Answer: 11
5174
5275If reading the byte 0x21 as a number, what decimal number would it mean?
53- Answer:
76+ Answer: 33
5477
5578If reading the byte 0x21 as an ASCII character, what character would it mean?
56- Answer:
79+ Answer: !
5780
5881If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
59- Answer:
82+ Answer: 33
6083
6184If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
62- Answer:
85+ Answer: maybe purpler
6386
6487If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
65- Answer:
88+ Answer: 170, 0, 255
89+
90+ AA00FF
91+ 1010 1010. 0000 0000. 1111 1111
92+ 0000 0000 - 0
93+ 1111 1111 - 255
94+ 1010 1010 - 2^7+0+2^5+0+2^3+0+2^1+0 = 170
0 commit comments