Skip to content

Commit 407d7a1

Browse files
committed
feat: add answers to Q16-Q20 powers of two and multi-byte interpretation
1 parent 66a9c41 commit 407d7a1

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

number-systems/Part-2.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ The goal of these exercises is for you to gain an intuition for binary numbers.
77
The answers to these questions will require a bit of explanation, not just a simple answer.
88

99
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 power of two in binary has only one 1 bit, followed by zero or more 0 bits: 2² = 4 = 100₂, 2⁴ = 16 = 10000₂
1111

1212
Q17: If reading the byte 0x21 as an ASCII character, what character would it mean?
13-
Answer:
13+
Answer: (2 × 16) + (1 × 1) = 32 + 1 = 33₁₀ ASCII value 33 = character '!'
1414

1515
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 = 33₁₀ If we consider greyscale range: 0 (black) to 255 (white), 33 is very close to 0, so it's a very dark grey
1717

1818
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: 0xAA = (10 × 16) + (10 × 1) = 160 + 10 = 170₁₀
20+
0x00 = (0 × 16) + (0 × 1) = 0₁₀
21+
0xFF = (15 × 16) + (15 × 1) = 240 + 15 = 255₁₀
2022

2123
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:
24+
Answer: Red = 170₁₀ (high, but not maximum)
25+
Green = 0₁₀ (none)
26+
Blue = 255₁₀ (maximum)
27+
Red + Blue = violet/purple
28+
Since Blue is max and Red is substantial, it leans toward Blue-Violet

0 commit comments

Comments
 (0)