Exercises 2.6 Exercises
1.
Convert \(123_{10}\) to binary.
2.
Convert the following unsigned decimal integers to 8-bit hexadecimal representation:
\(\displaystyle 100\)
\(\displaystyle 125\)
\(\displaystyle 10\)
\(\displaystyle 88\)
\(\displaystyle 255\)
\(\displaystyle 16\)
\(\displaystyle 32\)
\(\displaystyle 128\)
\(\displaystyle \hex{64}\)
\(\displaystyle \hex{7d}\)
\(\displaystyle \hex{0a}\)
\(\displaystyle \hex{58}\)
\(\displaystyle \hex{ff}\)
\(\displaystyle \hex{10}\)
\(\displaystyle \hex{20}\)
\(\displaystyle \hex{80}\)
3.
Convert the following unsigned decimal integers to 16-bit hexadecimal representation:
\(\displaystyle 1024\)
\(\displaystyle 1000\)
\(\displaystyle 32768\)
\(\displaystyle 32767\)
\(\displaystyle 256\)
\(\displaystyle 65535\)
\(\displaystyle 4660\)
\(\displaystyle 43981\)
\(\displaystyle \hex{0400}\)
\(\displaystyle \hex{03e8}\)
\(\displaystyle \hex{8000}\)
\(\displaystyle \hex{7fff}\)
\(\displaystyle \hex{0100}\)
\(\displaystyle \hex{ffff}\)
\(\displaystyle \hex{1234}\)
\(\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?
Since there are 12 values, we need 4 bits. Any 4-bit code would work. Here is one example:
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}\) |