From 47ae7e25e571cb73cb515c27b503b040351da4d8 Mon Sep 17 00:00:00 2001 From: Laura C Date: Sun, 22 Nov 2026 21:33:42 +0000 Subject: [PATCH 1/7] Convert 14 to binary for Q1 --- number-systems/Part-1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/number-systems/Part-1.md b/number-systems/Part-1.md index d8f9c290e..b718fe555 100644 --- a/number-systems/Part-1.md +++ b/number-systems/Part-1.md @@ -7,7 +7,7 @@ The goal of these exercises is for you to gain an intuition for binary numbers. The answers to these questions should be a number, either in binary, hex, or decimal. Q1: Convert the decimal number 14 to binary. -Answer: +Answer: 1110 Q2: Convert the binary number 101101 to decimal: Answer: From b00dc22bad26053b9eacfd8ff81f2a700f8c5e21 Mon Sep 17 00:00:00 2001 From: Laura C Date: Sun, 22 Nov 2026 21:41:04 +0000 Subject: [PATCH 2/7] Convert 101101 to decimal for Q2 --- number-systems/Part-1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/number-systems/Part-1.md b/number-systems/Part-1.md index b718fe555..8c984d4a4 100644 --- a/number-systems/Part-1.md +++ b/number-systems/Part-1.md @@ -10,7 +10,7 @@ Q1: Convert the decimal number 14 to binary. Answer: 1110 Q2: Convert the binary number 101101 to decimal: -Answer: +Answer: 45 Q3: Which is larger: 1000 or 0111? Answer: From 63094f2c3cf2df05f1dfd9515c743eb1068b9f8d Mon Sep 17 00:00:00 2001 From: Laura C Date: Sun, 22 Nov 2026 21:42:14 +0000 Subject: [PATCH 3/7] Compare the binary numbers in Q3 --- number-systems/Part-1.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/number-systems/Part-1.md b/number-systems/Part-1.md index 8c984d4a4..a03045eac 100644 --- a/number-systems/Part-1.md +++ b/number-systems/Part-1.md @@ -13,7 +13,9 @@ Q2: Convert the binary number 101101 to decimal: Answer: 45 Q3: Which is larger: 1000 or 0111? -Answer: +Answer: 1000 + +I compared the bits from the left. The first bit is already different: 1000 has a 1 there and 0111 has a 0, so 1000 is bigger. Q4: Which is larger: 00100 or 01011? Answer: From f1cb6a88fdba33ecc0326116e52ebd31a2ec7247 Mon Sep 17 00:00:00 2001 From: Laura C Date: Sun, 22 Nov 2026 21:43:31 +0000 Subject: [PATCH 4/7] Compare the binary numbers in Q4 --- number-systems/Part-1.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/number-systems/Part-1.md b/number-systems/Part-1.md index a03045eac..d8dab01ce 100644 --- a/number-systems/Part-1.md +++ b/number-systems/Part-1.md @@ -18,7 +18,9 @@ Answer: 1000 I compared the bits from the left. The first bit is already different: 1000 has a 1 there and 0111 has a 0, so 1000 is bigger. Q4: Which is larger: 00100 or 01011? -Answer: +Answer: 01011 + +Both numbers start with 0. The next digit is 1 in 01011 and 0 in 00100, so 01011 is bigger. Q5: What is 10101 + 01010? Answer: From 3825e9556c8b08d526aff3a979b6f94c7b9dc8d5 Mon Sep 17 00:00:00 2001 From: Laura C Date: Sun, 22 Nov 2026 21:50:19 +0000 Subject: [PATCH 5/7] Answer number systems questions 5 to 16 --- number-systems/Part-1.md | 44 ++++++++++++++++++++++++++++++---------- number-systems/Part-2.md | 4 +++- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/number-systems/Part-1.md b/number-systems/Part-1.md index d8dab01ce..f7d28a419 100644 --- a/number-systems/Part-1.md +++ b/number-systems/Part-1.md @@ -23,36 +23,58 @@ Answer: 01011 Both numbers start with 0. The next digit is 1 in 01011 and 0 in 00100, so 01011 is bigger. Q5: What is 10101 + 01010? -Answer: +Answer: 11111 + +Each column has one 1 and one 0, so every column gives 1 and there are no carries. Q6: What is 10001 + 10001? -Answer: +Answer: 100010 + +The rightmost 1 + 1 gives 0 and carries 1 into the next column. The two leftmost 1s also give 0 and carry 1 into a new column. Q7: What's the largest number you can store with 4 bits, if you want to be able to represent the number 0? -Answer: +Answer: 1111 + +Setting all four bits to 1 gives the largest unsigned value. Q8: How many bits would you need in order to store the numbers between 0 and 255 inclusive? -Answer: +Answer: 8 + +Eight bits give 256 different patterns, enough for every number from 0 through 255. Q9: How many bits would you need in order to store the numbers between 0 and 3 inclusive? -Answer: +Answer: 2 + +Two bits give four patterns: 00, 01, 10, and 11. Q10: How many bits would you need in order to store the numbers between 0 and 1000 inclusive? -Answer: +Answer: 10 + +Nine bits give 512 patterns. Ten bits give 1024, enough for all 1001 values from 0 through 1000. Q11: Convert the decimal number 14 to hex. -Answer: +Answer: E + +Hex uses A through F for the values 10 through 15, so 14 is E. Q12: Convert the decimal number 386 to hex. -Answer: +Answer: 182 + +386 is one group of 256, eight groups of 16, and two ones. Those are the three hex digits. Q13: Convert the hex number 386 to decimal. -Answer: +Answer: 902 + +The digits are worth 3 × 256, 8 × 16, and 6 × 1. Adding 768, 128, and 6 gives 902. Q14: Convert the hex number B to decimal. -Answer: +Answer: 11 + +In hex, A is 10 and B is the next digit, so B is 11. Q15: If reading the byte 0x21 as a number, what decimal number would it mean? -Answer: +Answer: 33 + +The 2 is in the sixteens place and the 1 is in the ones place. That gives 32 + 1 = 33. Q16: Continues in Part-2 diff --git a/number-systems/Part-2.md b/number-systems/Part-2.md index 68b0933d9..963cc4924 100644 --- a/number-systems/Part-2.md +++ b/number-systems/Part-2.md @@ -7,7 +7,9 @@ The goal of these exercises is for you to gain an intuition for binary numbers. The answers to these questions will require a bit of explanation, not just a simple answer. Q16: How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? -Answer: +Answer: Look for exactly one 1 bit. + +Each bit position represents a power of two. If exactly one bit is set, the number is the value of that position. Zero has no set bits. Q17: If reading the byte 0x21 as an ASCII character, what character would it mean? Answer: From 6ebfcdfe793bbc7426eec58c28fe83991dd3cdd1 Mon Sep 17 00:00:00 2001 From: Laura C Date: Sun, 22 Nov 2026 22:06:53 +0000 Subject: [PATCH 6/7] Finish Part 2 of the number systems exercises --- number-systems/Part-2.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/number-systems/Part-2.md b/number-systems/Part-2.md index 963cc4924..95b566e52 100644 --- a/number-systems/Part-2.md +++ b/number-systems/Part-2.md @@ -7,18 +7,24 @@ The goal of these exercises is for you to gain an intuition for binary numbers. The answers to these questions will require a bit of explanation, not just a simple answer. Q16: How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? -Answer: Look for exactly one 1 bit. - -Each bit position represents a power of two. If exactly one bit is set, the number is the value of that position. Zero has no set bits. +Answer: I just count the `1`s. If there’s exactly one, it’s a power of two. `1000` has one `1`, so it counts. `1010` has two, so it doesn’t... Q17: If reading the byte 0x21 as an ASCII character, what character would it mean? -Answer: +Answer: An exclamation mark (!). + +The hex value 0x21 is 33 in decimal and ASCII is a table that assigns a character to each code number, and code 33 is the exclamation mark. Q18: If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer: +Answer: Probably a very dark grey. + +In 8-bit greyscale, 0 means black and 255 means white. The value 0x21 is 33, which is much closer to 0 than to 255. That puts it near the black end of the scale... Q19: If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be? -Answer: +Answer: 170, 0, and 255. + +Each pair of hex digits is one byte, so split 0xAA00FF into AA, 00, and FF. A is 10, so AA is 10 x 16 + 10 = 170. The middle byte is 0. F is 15, so FF is 15 x 16 + 15 = 255. Q20: If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? -Answer: +Answer: A nice vivid purple. + +RGB reads the three bytes in red, green, blue order. That gives red 170, green 0, and blue 255. Red and blue together make purple, and the stronger blue gives it a bluish tint. From 52122e2bebe51b69568af7edf835eff2adb2cdd1 Mon Sep 17 00:00:00 2001 From: Laura C Date: Sun, 22 Nov 2026 22:17:44 +0000 Subject: [PATCH 7/7] Fix Q7 mistake --- number-systems/Part-1.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/number-systems/Part-1.md b/number-systems/Part-1.md index f7d28a419..264ebc8d6 100644 --- a/number-systems/Part-1.md +++ b/number-systems/Part-1.md @@ -33,9 +33,9 @@ Answer: 100010 The rightmost 1 + 1 gives 0 and carries 1 into the next column. The two leftmost 1s also give 0 and carry 1 into a new column. Q7: What's the largest number you can store with 4 bits, if you want to be able to represent the number 0? -Answer: 1111 +Answer: 15 -Setting all four bits to 1 gives the largest unsigned value. +Four bits give 2 x 2 x 2 x 2 = 16 possible patterns. Counting from 0, the last value is 15, represented by 1111. Q8: How many bits would you need in order to store the numbers between 0 and 255 inclusive? Answer: 8