Skip to content

Commit f4ec890

Browse files
committed
Number system: complete part 2
1 parent 395e2f2 commit f4ec890

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎number-systems/Part-2.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ 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 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.
1111

1212
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 "!".
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 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).
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: 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.
2020

2121
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

Comments
 (0)