Skip to content

Commit b20a8c4

Browse files
committed
completed answers for number-systems
1 parent 0befc43 commit b20a8c4

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

number-systems/README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ Convert the binary number 101101 to decimal:
1111
Answer: 2^5 + 2^3 + 2^2 + 2^0 = 32 + 8 + 4 + 1 = 45
1212

1313
Which is larger: 1000 or 0111?
14-
Answer: 1000 because 1000 is 8 and 0111 is 7
14+
Answer: 1000 is larger because 1000 has more places
1515

1616
Which is larger: 00100 or 01011?
17-
Answer: 01011 because 01011 is 11 and 00100 is 4
17+
Answer: 01011 is larger because it has more places
1818

1919
What is 10101 + 01010?
2020
Answer: 11111
@@ -34,8 +34,8 @@ Answer: 2 bits as 00 = 0, and 11 = 3
3434
How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
3535
Answer: 2^9 = 512
3636
2^8 = 256
37-
2^7 = 128
38-
2^6 = 64
37+
2^7 = 128
38+
2^6 = 64
3939
2^3 = 8
4040
512 + 256 + 128 + 64 + 32 + 8 = 1000
4141
b1111101000 = 1000
@@ -44,39 +44,38 @@ we need 10 bits
4444
How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
4545
Answer: 1, 10, 100, 1000, 10000
4646
1, 2, 4, 8, 16
47-
If the binary starts with 1 or 1 followed by 0s, it will be a power of two.
47+
If the binary number is 1 or 1 followed by 0s, it will be a power of two.
4848
We can use regexp to test the binary number.
4949

50-
function testPowerOfTwo(binaryNumber) {
51-
return /^0*10*$/.test(String(binaryNumber))
52-
}
50+
function testPowerOfTwo(binaryNumber) {
51+
return /^0*10*$/.test(String(binaryNumber))
52+
}
5353

5454
Convert the decimal number 14 to hex.
5555
Answer: 10 = A, 11 = B, 12 = C, 13 = D, 14 = E
5656

5757
Convert the decimal number 386 to hex.
58-
Answer: F = 15,
59-
386 / 15 = 25.7333
60-
386 - (F * 25) = 11
61-
So, 386 = F*25+B
58+
Answer: 386 - 16^2 = 130
59+
130 - 16 x 8 = 2
60+
hex: 182
6261

6362
Convert the hex number 386 to decimal.
64-
Answer:
63+
Answer: 3 x 16^2 + 8 x 16 + 6 x 1 = 902
6564

6665
Convert the hex number B to decimal.
67-
Answer:
66+
Answer: 11
6867

6968
If reading the byte 0x21 as a number, what decimal number would it mean?
70-
Answer:
69+
Answer: 2 x 16 + 1 X 1 = 33
7170

7271
If reading the byte 0x21 as an ASCII character, what character would it mean?
73-
Answer:
72+
Answer: !
7473

7574
If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
76-
Answer:
75+
Answer: As the byte 0x21 is 33 in decimal, which is in the range of 0 full black to 255 full white. The color is close to black.
7776

7877
If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
79-
Answer:
78+
Answer: AA (170) means middle high red, 00 means no green, and FF (255) means full blue. The colour should be purple.
8079

8180
If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
82-
Answer:
81+
Answer: 170, 0, 255

0 commit comments

Comments
 (0)