Skip to content

Commit 5b38f3e

Browse files
committed
number-system
1 parent 407b010 commit 5b38f3e

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

number-systems/README.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,67 @@ Do not convert any binary numbers to decimal when solving a question unless the
55
The goal of these exercises is for you to gain an intuition for binary numbers. Using tools to solve the problems defeats the point.
66

77
Convert the decimal number 14 to binary.
8-
Answer:
8+
Answer: 1110
99

1010
Convert the binary number 101101 to decimal:
11-
Answer:
11+
Answer: 45
1212

1313
Which is larger: 1000 or 0111?
14-
Answer:
14+
Answer: 1000
1515

1616
Which is larger: 00100 or 01011?
17-
Answer:
17+
Answer: 01011
1818

1919
What is 10101 + 01010?
20-
Answer:
20+
Answer: 11111
2121

2222
What is 10001 + 10001?
23-
Answer:
23+
Answer: 100010
2424

2525
What's the largest number you can store with 4 bits, if you want to be able to represent the number 0?
26-
Answer:
26+
Answer: 15
2727

2828
How many bits would you need in order to store the numbers between 0 and 255 inclusive?
29-
Answer:
29+
Answer: 8 bits
3030

3131
How many bits would you need in order to store the numbers between 0 and 3 inclusive?
32-
Answer:
32+
Answer: 2 bits
3333

3434
How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
35-
Answer:
35+
Answer: 10 bits
3636

3737
How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
38-
Answer:
38+
Answer:
39+
Powers of two in binary: 1, 10, 100, 1000...
40+
Subtracting 1 flips all bits after the single 1
41+
Example: 8 = 1000, 8-1=7=0111
42+
1000 & 0111 = 0
43+
3944

4045
Convert the decimal number 14 to hex.
41-
Answer:
46+
Answer: E
4247

4348
Convert the decimal number 386 to hex.
44-
Answer:
49+
Answer: 0x182
4550

4651
Convert the hex number 386 to decimal.
47-
Answer:
52+
Answer: 902
4853

4954
Convert the hex number B to decimal.
50-
Answer:
55+
Answer: 11
56+
5157

5258
If reading the byte 0x21 as a number, what decimal number would it mean?
53-
Answer:
59+
Answer: 33
5460

5561
If reading the byte 0x21 as an ASCII character, what character would it mean?
56-
Answer:
62+
Answer: !
5763

5864
If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
59-
Answer:
65+
Answer: dark gray shade
6066

6167
If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
62-
Answer:
68+
Answer: bright purple/magenta
6369

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

0 commit comments

Comments
 (0)