You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f4ec890
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: number-systems/Part-2.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,16 @@ The goal of these exercises is for you to gain an intuition for binary numbers.
7
7
The answers to these questions will require a bit of explanation, not just a simple answer.
8
8
9
9
Q16: How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
10
-
Answer:
10
+
Answer: A binary number is a power of two only if it has exactly one 1 digit, and all the other digits are 0. This is because each place value is a power of two, so one 1 means the number is just that power. Two or more 1s add powers together (like 8 + 2 = 10), which is not a power of two.
11
11
12
12
Q17: If reading the byte 0x21 as an ASCII character, what character would it mean?
13
-
Answer:
13
+
Answer: 0x21 is 33 in decimal. In the ASCII table, 33 is the character "!".
14
14
15
15
Q18: If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
16
-
Answer:
16
+
Answer: 0x21 is 33 in decimal. In greyscale, 0 is black and 255 is white. 33 is close to 0, so it is a dark grey (almost black).
17
17
18
18
Q19: If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
19
-
Answer:
19
+
Answer: Split 0xAA00FF into three bytes: AA, 00, FF. AA = 10 × 16 + 10 = 170, 00 = 0, FF = 15 × 16 + 15 = 255. So the numbers are 170, 0, 255.
20
20
21
21
Q20: If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
22
-
Answer:
22
+
Answer: Read 0xAA00FF as three bytes: R = AA = 170, G = 00 = 0, B = FF = 255. That’s lots of red, no green and full blue, so the colour is purple (a bluish purple / violet).
0 commit comments