## Exercises2.6Exercises

###### 1.

Convert $123_{10}$ to binary.

Hint

123 % 2 = 1 so $d_{0} = 1\text{.}$ Then since 123 / 2 = 61, the next computation is 61 % 2 = 1.

$\binary{1111011} = \hex{7b}$

###### 2.

Convert the following unsigned decimal integers to 8-bit hexadecimal representation:

1. $\displaystyle 100$

2. $\displaystyle 125$

3. $\displaystyle 10$

4. $\displaystyle 88$

5. $\displaystyle 255$

6. $\displaystyle 16$

7. $\displaystyle 32$

8. $\displaystyle 128$

1. $\displaystyle \hex{64}$

2. $\displaystyle \hex{7d}$

3. $\displaystyle \hex{0a}$

4. $\displaystyle \hex{58}$

5. $\displaystyle \hex{ff}$

6. $\displaystyle \hex{10}$

7. $\displaystyle \hex{20}$

8. $\displaystyle \hex{80}$

###### 3.

Convert the following unsigned decimal integers to 16-bit hexadecimal representation:

1. $\displaystyle 1024$

2. $\displaystyle 1000$

3. $\displaystyle 32768$

4. $\displaystyle 32767$

5. $\displaystyle 256$

6. $\displaystyle 65535$

7. $\displaystyle 4660$

8. $\displaystyle 43981$

1. $\displaystyle \hex{0400}$

2. $\displaystyle \hex{03e8}$

3. $\displaystyle \hex{8000}$

4. $\displaystyle \hex{7fff}$

5. $\displaystyle \hex{0100}$

6. $\displaystyle \hex{ffff}$

7. $\displaystyle \hex{1234}$

8. $\displaystyle \hex{abcd}$

###### 4.

Invent a code that would allow us to store letter grades with plus or minus. That is, the grades A, A-, B+, B, B-,…, D, D-, F. How many bits are required for your code?

 Grade Code (in hex) A $\binary{0000}$ $\hex{0}$ A- $\binary{0001}$ $\hex{1}$ B+ $\binary{0010}$ $\hex{2}$ B $\binary{0011}$ $\hex{3}$ B- $\binary{0100}$ $\hex{4}$ C+ $\binary{0101}$ $\hex{5}$ C $\binary{0110}$ $\hex{6}$ C- $\binary{0111}$ $\hex{7}$ D+ $\binary{1000}$ $\hex{8}$ D $\binary{1001}$ $\hex{9}$ D- $\binary{1010}$ $\hex{a}$ F $\binary{1011}$ $\hex{b}$