Skip to content

Commit 1510551

Browse files
committed
number-systems-solutions
1 parent 407b010 commit 1510551

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

number-systems/README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,59 +7,100 @@ The goal of these exercises is for you to gain an intuition for binary numbers.
77
Convert the decimal number 14 to binary.
88
Answer:
99

10+
1110
11+
1012
Convert the binary number 101101 to decimal:
1113
Answer:
1214

15+
32,8,4,1 = 45
16+
1317
Which is larger: 1000 or 0111?
1418
Answer:
1519

20+
1000 is larger since it has more leading ones ( literally digit 1) compared to 0111. By leading one, i mean the outer most on the left side.
21+
1622
Which is larger: 00100 or 01011?
1723
Answer:
1824

25+
01011 is larger as it is got again the more leading ones ( digit 1) on the left side.
26+
1927
What is 10101 + 01010?
2028
Answer:
29+
It is 11111
2130

2231
What is 10001 + 10001?
2332
Answer:
33+
It is 100010
34+
2435

2536
What's the largest number you can store with 4 bits, if you want to be able to represent the number 0?
2637
Answer:
2738

39+
Answer1: If representing 0 means having 0000 AS A POSSIBLE NUMBER in the range of 0 to largest number produced by four digits, then the largest possible number is when all the digits are one which makes 1111 the largest number.
40+
41+
Answer2: If it means having 0 in one of the digits as a possible occurrence, then the largest possible number produced when zero goes to the last digit to have the least effect which 1110 the largest number.
42+
2843
How many bits would you need in order to store the numbers between 0 and 255 inclusive?
2944
Answer:
3045

46+
since 256 is 2^8 the biggest number of digits with 255 inclusive is made when we have 8 digits.
47+
3148
How many bits would you need in order to store the numbers between 0 and 3 inclusive?
3249
Answer:
3350

51+
2 bits.
52+
3453
How many bits would you need in order to store the numbers between 0 and 1000 inclusive?
3554
Answer:
3655

56+
10 bits. since 2^n - 1 = the biggest number with n bits.
57+
3758
How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)?
3859
Answer:
3960

61+
if a number is a power of 2, then it has only one bit as 1 and the rest are zeros.
62+
4063
Convert the decimal number 14 to hex.
4164
Answer:
65+
It is E
4266

4367
Convert the decimal number 386 to hex.
4468
Answer:
69+
ox182
4570

4671
Convert the hex number 386 to decimal.
4772
Answer:
73+
6*(16^0)+8*(16^1)+3*(16^2) = 902
4874

4975
Convert the hex number B to decimal.
5076
Answer:
77+
It is 11
5178

5279
If reading the byte 0x21 as a number, what decimal number would it mean?
5380
Answer:
81+
2(16^1)+1(16^0) = 33
5482

5583
If reading the byte 0x21 as an ASCII character, what character would it mean?
5684
Answer:
85+
!
5786

58-
If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
87+
If reading the byte ox21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
5988
Answer:
6089

90+
Since Ox21 is 33 in decimal and we have a range of 0(black) to 255(white) in decimal, then 33 is relatively close to zero. So it the gray scale it a dark grey
91+
6192
If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean?
6293
Answer:
6394

95+
Each set of 2 hex digits stands for each of primary colors in the following order:
96+
RRGGBB: comparing it to AA00FF means that we don't have any greens. so we would have a mixture of blue and red. So eventually we have shade of purpule
97+
98+
6499
If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be?
65100
Answer:
101+
102+
So A in hex represents 10 in decimal
103+
And F in hex represent 15, so:
104+
AA => (16^0)*10 + (16^1)*10 = 10+160 = 170;
105+
00 => 0
106+
FF => (16^0)*15 + (16^1)*15 = 15+240 = 255

0 commit comments

Comments
 (0)