Number Systems Exercises
This 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
MSB | LSB | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
$$2^{10}$$ | $$2^{9}$$ | $$2^{8}$$ | $$2^{7}$$ | $$2^{6}$$ | $$2^{5}$$ | $$2^{4}$$ | $$2^{3}$$ | $$2^{2}$$ | $$2^{1}$$ | $$2^{0}$$ |
1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
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.
MSB | LSB | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
$$2^{10}$$ | $$2^{9}$$ | $$2^{8}$$ | $$2^{7}$$ | $$2^{6}$$ | $$2^{5}$$ | $$2^{4}$$ | $$2^{3}$$ | $$2^{2}$$ | $$2^{1}$$ | $$2^{0}$$ |
1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
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 |
---|---|---|---|---|---|---|---|---|
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | |
1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | |
1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | |
0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | |
1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | |
0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | |
1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | |
1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | |
0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 |
Click for solutions
$$2^7$$ | $$2^6$$ | $$2^5$$ | $$2^4$$ | $$2^3$$ | $$2^2$$ | $$2^1$$ | $$2^0$$ | Decimal |
---|---|---|---|---|---|---|---|---|
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 85 |
1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 253 |
1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 130 |
0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 14 |
1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 201 |
0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 34 |
1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 221 |
1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 173 |
0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 50 |
Decimal to Binary Conversion
To convert from decimal to Binary, we have two options: The first of these involves continually dividing by two, and is explained in the PowerPoint presentation. The second way is the shorter way and it involves dividing through by the positional values rather than two. For example:
$$171_{10}$$
The largest positional value which will divide into \(171_{10}\) once is \(2^7\) which is equal to \(128_{10}\). We therefore place a 1 in the \(2^7\) column, and subtract \(128_{10}\) from \(171_{10}\):
MSB | LSB | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
$$2^{10}$$ | $$2^{9}$$ | $$2^{8}$$ | $$2^{7}$$ | $$2^{6}$$ | $$2^{5}$$ | $$2^{4}$$ | $$2^{3}$$ | $$2^{2}$$ | $$2^{1}$$ | $$2^{0}$$ |
1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 |
\[ \begin{aligned} & 171_{10}\\ & 128_{10} \hspace{1em} - \\ \hline & \hspace{0.5em}43_{10} \end{aligned} \]
- 43 is less than 64, so we put a 0 in the \(2^6\) column and move on to the \(2^5\) column. 43 is greater than 32, so we put a 1 in the \(2^5\) column and subtract 32 from 43:
MSB | LSB | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
$$2^{10}$$ | $$2^{9}$$ | $$2^{8}$$ | $$2^{7}$$ | $$2^{6}$$ | $$2^{5}$$ | $$2^{4}$$ | $$2^{3}$$ | $$2^{2}$$ | $$2^{1}$$ | $$2^{0}$$ |
1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 |
\[ \begin{aligned} & 43_{10}\\ & 32_{10} \hspace{1em} - \\ \hline & 11_{10} \end{aligned} \]
- 11 is less than 16, so we put a 0 in the \(2^4\) column and move on to the \(2^3\) column. 11 is greater than 8, so we put a 1 in the \(2^3\) column and subtract 8 from 11:
MSB | LSB | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
$$2^{10}$$ | $$2^{9}$$ | $$2^{8}$$ | $$2^{7}$$ | $$2^{6}$$ | $$2^{5}$$ | $$2^{4}$$ | $$2^{3}$$ | $$2^{2}$$ | $$2^{1}$$ | $$2^{0}$$ |
1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 | 0 | 1 |
\[ \begin{aligned} & 11_{10}\\ & \hspace{0.5em}8_{10} \hspace{1em}- \\ \hline & \hspace{0.5em}3_{10} \end{aligned} \]
- 3 is less than 4, so we put a 0 in the \(2^2\) column and move on to the \(2^1\) column. 3 is greater than 2, so we put a 1 in the \(2^1\) column and subtract 2 from 3:
MSB | LSB | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
$$2^{10}$$ | $$2^{9}$$ | $$2^{8}$$ | $$2^{7}$$ | $$2^{6}$$ | $$2^{5}$$ | $$2^{4}$$ | $$2^{3}$$ | $$2^{2}$$ | $$2^{1}$$ | $$2^{0}$$ |
1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 | 0 | 1 | 0 | 1 | 1 |
\[ \begin{aligned} & 1_{10}\\ & 1_{10} \hspace{1em}- \\ \hline & 0_{10} \end{aligned} \]
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$$ |
---|---|---|---|---|---|---|---|---|
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
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$$ |
---|---|---|---|---|---|---|---|---|
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
165 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |
242 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 0 |
7 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
92 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 |
63 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
12 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
129 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
71 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 |
45 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |