Skip to main content

Exercises 2.4 Exercises

1.

Referring to Equation (2.3.3), what are the values of \(r\text{,}\) \(n\) and each \(d_{i}\) for the decimal number \(29458254\text{?}\) The hexadecimal number \(\hex{29458254}\text{?}\)

Answer

Decimal number: \(r = 10, n = 8, d_{7} = 2, d_{6} = 9, d_{5} = 4, d_{4} = 5, d_{3} = 8, d_{2} = 2, d_{1} = 5, d_{0} = 4\)

Hexadecimal number: \(r = 16, n = 8, d_{7} = 2, d_{6} = 9, d_{5} = 4, d_{4} = 5, d_{3} = 8, d_{2} = 2, d_{1} = 5, d_{0} = 4\)

2.

Convert the eight-digit binary number \(\binary{1010} \; \binary{0101}\) to decimal.

Answer
\begin{align*} \binary{1010} \; \binary{0101}_{2} &= 1 \times 2^{7} + 0 \times 2^{6} + 1 \times 2^{5} + 0 \times 2^{4} + 0 \times 2^{3} + 1 \times 2^{2} + 0 \times 2^{1} + 1 \times 2^{0}\\ &= 128 + 0 + 32 + 0 + 0 + 4 + 0 + 1 \\ &= 165_{10} \end{align*}
3.

Convert the following 8-bit binary numbers to decimal by hand:

  1. \(\displaystyle \binary{1010} \; \binary{1010} \)

  2. \(\displaystyle \binary{0101} \; \binary{0101} \)

  3. \(\displaystyle \binary{1111} \; \binary{0000} \)

  4. \(\displaystyle \binary{0000} \; \binary{1111} \)

  5. \(\displaystyle \binary{1000} \; \binary{0000} \)

  6. \(\displaystyle \binary{0110} \; \binary{0011} \)

  7. \(\displaystyle \binary{0111} \; \binary{1011} \)

  8. \(\displaystyle \binary{1111} \; \binary{1111} \)

Answer
  1. \(\displaystyle 170\)

  2. \(\displaystyle 85\)

  3. \(\displaystyle 240\)

  4. \(\displaystyle 15\)

  5. \(\displaystyle 128\)

  6. \(\displaystyle 99\)

  7. \(\displaystyle 123\)

  8. \(\displaystyle 255\)

4.

Convert the following 16-bit binary numbers to decimal by hand:

  1. \(\displaystyle \binary{1010} \; \binary{1011} \; \binary{1100} \; \binary{1101}\)

  2. \(\displaystyle \binary{0001} \; \binary{0010} \; \binary{0011} \; \binary{0100}\)

  3. \(\displaystyle \binary{1111} \; \binary{1110} \; \binary{1101} \; \binary{1100}\)

  4. \(\displaystyle \binary{0000} \; \binary{0111} \; \binary{1101} \; \binary{1111}\)

  5. \(\displaystyle \binary{1000} \; \binary{0000} \; \binary{0000} \; \binary{0000}\)

  6. \(\displaystyle \binary{0000} \; \binary{0100} \; \binary{0000} \; \binary{0000}\)

  7. \(\displaystyle \binary{0111} \; \binary{1011} \; \binary{1010} \; \binary{1010}\)

  8. \(\displaystyle \binary{0011} \; \binary{0000} \; \binary{0011} \; \binary{1001}\)

Answer
  1. \(\displaystyle 43981\)

  2. \(\displaystyle 4660\)

  3. \(\displaystyle 65244\)

  4. \(\displaystyle 2015\)

  5. \(\displaystyle 32768\)

  6. \(\displaystyle 1024\)

  7. \(\displaystyle 31658\)

  8. \(\displaystyle 12345\)

5.

Develop an algorithm to convert hexadecimal to decimal, and then convert the following 16-bit numbers to decimal by hand:

  1. \(\displaystyle \hex{a000}\)

  2. \(\displaystyle \hex{ffff}\)

  3. \(\displaystyle \hex{0400}\)

  4. \(\displaystyle \hex{1111}\)

  5. \(\displaystyle \hex{8888}\)

  6. \(\displaystyle \hex{0190}\)

  7. \(\displaystyle \hex{abcd}\)

  8. \(\displaystyle \hex{5555}\)

Hint

Review the algorithm to convert binary to decimal above.

Answer
  1. Set \(Result = 0\)

  2. For \(i = 0, \cdots, (n-1)\)

    • \(\displaystyle Result = Result + d_{i} * 16^{i}\)

  1. \(\displaystyle 40960\)

  2. \(\displaystyle 65535\)

  3. \(\displaystyle 1024\)

  4. \(\displaystyle 4369\)

  5. \(\displaystyle 34952\)

  6. \(\displaystyle 400\)

  7. \(\displaystyle 43981\)

  8. \(\displaystyle 21845\)