@@ -6,60 +6,67 @@ 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-
9+ 1110
1010Convert the binary number 101101 to decimal:
1111Answer:
12-
12+ 45
1313Which is larger: 1000 or 0111?
1414Answer:
15-
15+ 1000 = 8
16+ 0111 = 7
17+ 1000 is larger
1618Which is larger: 00100 or 01011?
1719Answer:
18-
20+ 00100 = 4
21+ 01011 = 11
22+ 01011 is larger
1923What is 10101 + 01010?
2024Answer:
21-
25+ 10101 = 21
26+ 01010 = 10
27+ 21+10 = 31
2228What is 10001 + 10001?
2329Answer:
24-
30+ 10001 = 17
31+ 17+ 17 = 34
2532What's the largest number you can store with 4 bits, if you want to be able to represent the number 0?
2633Answer:
27-
34+ 1111 = 15
2835How many bits would you need in order to store the numbers between 0 and 255 inclusive?
2936Answer:
30-
37+ 11111111 = 8 bits
3138How many bits would you need in order to store the numbers between 0 and 3 inclusive?
3239Answer:
33-
40+ 11 = 2 bits
3441How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
3542Answer:
36-
43+ 1111101000 = 10 bits = 1024
3744How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
3845Answer:
39-
46+ if the bit have only '1' in it, means i'ts a power of two, if have multiple '1' that's not.
4047Convert the decimal number 14 to hex.
41- Answer:
48+ Answer: E
4249
4350Convert the decimal number 386 to hex.
44- Answer:
51+ Answer: 0x182
4552
4653Convert the hex number 386 to decimal.
47- Answer:
54+ Answer:902
4855
4956Convert the hex number B to decimal.
50- Answer:
57+ Answer: B = 11
5158
52- If reading the byte 0x21 as a number, what decimal number would it mean?
59+ If reading the byte 0x21 as a number, what decimal number would it mean?
5360Answer:
54-
61+ 33
5562If reading the byte 0x21 as an ASCII character, what character would it mean?
56- Answer:
63+ Answer: 0x21 = "!"
5764
5865If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
59- Answer:
66+ Answer: Dark Grey
6067
6168If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
62- Answer:
69+ Answer: Purple
6370
6471If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
65- Answer:
72+ Answer: 170 0 255
0 commit comments