Number Systems Exercises

The Number System lab is designed for you to practice converting between different bases.

Binary Numbers

Binary is a base 2 numbering system. There are only two symbols used, 0 and 1.

Binary Positional Values

MSBLSB
$$2^{10}$$$$2^{9}$$$$2^{8}$$$$2^{7}$$$$2^{6}$$$$2^{5}$$$$2^{4}$$$$2^{3}$$$$2^{2}$$$$2^{1}$$$$2^{0}$$
10245122561286432168421

Binary to Decimal Conversion

To convert from binary to decimal, we need to add together the positional values for all the columns containing a 1. We ignore the columns with a 0, as they have nothing in them.

MSBLSB
$$2^{10}$$$$2^{9}$$$$2^{8}$$$$2^{7}$$$$2^{6}$$$$2^{5}$$$$2^{4}$$$$2^{3}$$$$2^{2}$$$$2^{1}$$$$2^{0}$$
10245122561286432168421
00010010110

In the above example, there are 1s in the \(2^7\), \(2^4\), \(2^2\) and \(2^1\) columns.

Therefore the decimal equivalent value is:

\[ \begin{aligned} 2^7 &= 128\\ 2^4 &= \hspace{0.5em}16 \\ 2^2 &= \hspace{1em} 4 \\ 2^1 &= \hspace{1em} 2 \hspace{0.5em}+ \\ \hline 000 1001 0110 & \equiv 150_{10} \end{aligned} \]

Binary to Decimal Conversion Exercises

Convert the following binary numbers into decimal:

$$2^7$$$$2^6$$$$2^5$$$$2^4$$$$2^3$$$$2^2$$$$2^1$$$$2^0$$Decimal
1286432168421
01010101
11111101
10000010
00001110
11001001
00100010
11011101
10101101
00110010


Click for solutions

$$2^7$$$$2^6$$$$2^5$$$$2^4$$$$2^3$$$$2^2$$$$2^1$$$$2^0$$Decimal
1286432168421
0101010185
11111101253
10000010130
0000111014
11001001201
0010001034
11011101221
10101101173
0011001050

Decimal to Binary Conversion

To convert from decimal to Binary, we have continually dividing by two, and is explained in the PowerPoint presentation.

  • Start with the Decimal Number:
    Let's take an example decimal number, say 23.

  • Divide the Number by 2:
    Divide the number by 2 and note down the quotient and the remainder.

    • ( 23 ÷ 2 = 11 ) remainder ( 1 ) So, our binary representation will start with a 1.
  • Continue Dividing:
    Take the quotient from the previous step (which is 11 in our case) and divide it by 2 again.

    • ( 11 ÷ 2 = 5 ) remainder ( 1 ) Append this remainder to the left of the previous remainder to get 11.
  • Repeat Until Quotient is 0:
    Continue the process of division by 2 until the quotient is 0.

    • ( 5 ÷ 2 = 2 ) remainder ( 1 )
    • ( 2 ÷ 2 = 1 ) remainder ( 0 )
    • ( 1 ÷ 2 = 0 ) remainder ( 1 )
  • Read the Remainders:
    Now, read the remainders from bottom to top. In our example, the remainders are 10111.

  • Result:
    The binary representation of the decimal number 23 is 10111.

Decimal to Binary Conversion Exercises

Convert the following decimal numbers into binary:

Decimal$$2^7$$$$2^6$$$$2^5$$$$2^4$$$$2^3$$$$2^2$$$$2^1$$$$2^0$$
1286432168421
165
242
7
92
63
12
129
71
45

Click for solutions

Decimal$$2^7$$$$2^6$$$$2^5$$$$2^4$$$$2^3$$$$2^2$$$$2^1$$$$2^0$$
1286432168421
16510100101
24211110010
700000111
9201011100
6300111111
1200001100
12910000001
7101000111
4500101101

Hexadecimal Numbers

Hexadecimal is a base 16 numbering system. It uses 0 to 9, like decimal, plus A to F:

0 1 2 3 4 5 6 7 8 9 A B C D E F

\(A_{16}\) = \(10_{10}\)

\(B_{16}\) = \(11_{10}\)

\(C_{16}\) = \(12_{10}\)

\(D_{16}\) = \(13_{10}\)

\(E_{16}\) = \(14_{10}\)

\(F_{16}\) = \(15_{10}\)

Hexadecimal Positional Values

MSBLSB
$$16^{3}$$$$16^{2}$$$$16^{1}$$$$16^{0}$$
4096256161

Hexadecimal to Decimal Conversion

To convert a number from hexadecimal to decimal, you need to multiply each digit in the hexadecimal number by the positional value of the column it is in, then add these all together. It is usual to work from left to right.

For example:

MSBLSB
$$16^{3}$$$$16^{2}$$$$16^{1}$$$$16^{0}$$
4096256161
13B5

\[ \begin{aligned} 1 * 4096 &= 4096\\ 3 * 256 &= \hspace{0.5em} 768 \\ B(11) * 16 &= \hspace{0.5em}176 \\ 5 * 1 &= \hspace{1.5em}5 \hspace{1em}+\\ \hline & \hspace{0.5em}5045_{10} \end{aligned} \]

Hexadecimal to Decimal Conversion Exercises

Convert the following hexadecimal numbers to decimal:

$$16^3$$$$16^2$$$$16^1$$$$16^0$$Answer
4096256161
05F9
2CAD
1955
A864
762B
14BE
0EDC
570A
1B32
2DC6

Click for solutions

$$16^3$$$$16^2$$$$16^1$$$$16^0$$Answer
4096256161
05F91529
2CAD11437
19556485
A86443108
762B30251
14BE5310
0EDC3804
570A22282
1B326962
2DC611718

Decimal to Hexadecimal Conversion

Converting a decimal number to hexadecimal involves repeatedly dividing it by 16, until the dividend equals 0. Each time, the remainder goes in the empty column nearest the right (least significant number).

An example should hopefully make this clearer:

$$4591_{10}$$

$$16^{3}$$$$16^{2}$$$$16^{1}$$$$16^{0}$$
4096256161

$$286 \hspace{0.5em}r 15= \frac{4591}{16}$$

15 = F, so put an F in the \(16^0\) column and divide the dividend (286) by 16

$$16^{3}$$$$16^{2}$$$$16^{1}$$$$16^{0}$$
4096256161
F

$$17 \hspace{0.5em}r 14= \frac{286}{16}$$

14 = E, so put an E in the \(16^1\) column and divide the dividend (17) by 16:

$$16^{3}$$$$16^{2}$$$$16^{1}$$$$16^{0}$$
4096256161
EF

$$1 \hspace{0.5em}r 1= \frac{17}{16}$$

Put the remainder 1 in the \(16^2\)column and divide the dividend (1) by 16:

$$16^{3}$$$$16^{2}$$$$16^{1}$$$$16^{0}$$
4096256161
1EF

$$0 \hspace{0.5em}r 1= \frac{1}{16}$$

Put the remainder in the \(16^3\) column. The dividend is 0, so our conversion is completed:

$$16^{3}$$$$16^{2}$$$$16^{1}$$$$16^{0}$$
4096256161
11EF

Decimal to Hexadecimal Conversion Exercises

Convert the following decimal numbers to hexadecimal:

Decimal$$16^3$$$$16^2$$$$16^1$$$$16^0$$
4096256161
4015
231
590
20371
32
926
15995
17612
8000
745

Click for solutions

Decimal$$16^3$$$$16^2$$$$16^1$$$$16^0$$
4096256161
40150FAF
23100E7
590024E
203714F93
320020
926039E
159953E7B
1761244CC
80001F40
74502E9

Converting From Hexadecimal to Binary

Converting between binary and hexadecimal is very easy, as \(2^4\) = \(16^1\).

This means that each hexadecimal character can be represented by a block of 4 binary digits.

To convert from Hexadecimal to Binary, you therefore convert each hexadecimal digit into 4 binary digits.

For example:

$$A39C_{16}$$

\(A_{16}\equiv 10_{10} \equiv1010_{2}\)

\(3_{16}\equiv 0011_{2}\)

\(9_{16}\equiv 1001_{2}\)

\(C_{16}\equiv 12_{10} \equiv1100_{2}\)

Putting it together we get:

  • \(1010 0011 1010 1100_{2}\)

Hexadecimal to Binary Conversion Exercises

Convert the following hexadecimal numbers to binary:

  1. \(0395_{16} \equiv\) ?

  2. \(BA92_{16} \equiv\) ?

  3. \(46C1_{16} \equiv\) ?

  4. \(78DF_{16} \equiv\) ?

  5. \(E129_{16} \equiv\) ?

  6. \(C416_{16} \equiv\) ?


Click for solutions

  1. \(0395_{16} \equiv\) \(0000 0011 1001 0101_{2}\)

  2. \(BA92_{16} \equiv\) \(1011 1010 1001 0010_{2}\)

  3. \(46C1_{16} \equiv\) \(0100 0110 1100 0001_{2}\)

  4. \(78DF_{16} \equiv\) \(0111 1000 1101 1111_{2}\)

  5. \(E129_{16} \equiv\) \(1110 0001 0010 1001_{2}\)

  6. \(C416_{16} \equiv\) \(1100 0100 0001 0110_{2}\)


Binary to Hexadecimal Conversion

To convert from binary to hexadecimal, start from the right (least significant bit) and break the binary number into blocks of 4 digits. Then convert each block to its hexadecimal equivalent.

For example:

\(1100 0011 0101 1111_{2}\)

\(1100_{2} \equiv12_{10} \equiv C_{16}\)

\(0011_{2} \equiv3_{16}\)

\(0101_{2} \equiv5_{16}\)

\(1111_{2} \equiv15_{10} \equiv F_{16}\)

Putting that all together we get \(C35F_{16}\)

Binary to Hexadecimal Conversion Exercises

Convert the following binary numbers to hexadecimal:

  1. \(1101 0011 0110 1101_{2}\equiv\) ?

  2. \(0010 1010 0101 0000_{2}\equiv\) ?

  3. \(1111 0110 1000 0001_{2}\equiv\) ?

  4. \(0001 0110 1001 1011_{2}\equiv\) ?

  5. \(1010 1011 0011 0101_{2}\equiv\) ?

  6. \(0101 0001 0010 0011_{2}\equiv\) ?


Click for solutions

  1. \(1101 0011 0110 1101_{2}\equiv\) \(D36D_{16}\)

  2. \(0010 1010 0101 0000_{2}\equiv\) \(2A50_{16}\)

  3. \(1111 0110 1000 0001_{2}\equiv\) \(F681_{16}\)

  4. \(0001 0110 1001 1011_{2}\equiv\) \(169B_{16}\)

  5. \(1010 1011 0011 0101_{2}\equiv\) \(AB35_{16}\)

  6. \(0101 0001 0010 0011_{2}\equiv\) \(5123_{16}\)