Skip to main content
Logo image

Section 11.2 Binary Representation

Before using any base \(b\text{,}\) where \(b\) is a natural number greater than \(1\text{,}\) we look at one more special case. One of the most common bases besides base \(10\) is base \(2\text{.}\) Base \(10\) numbers use the ten symbols \(0\text{,}\) \(1\text{,}\) \(2\text{,}\) \(3\text{,}\) \(4\text{,}\) \(5\text{,}\) \(6\text{,}\) \(7\text{,}\) \(8\text{,}\) and \(9\text{.}\) Base \(2\) numbers use only the two symbols
\begin{equation*} 0 \text{ and } 1. \end{equation*}
Base \(2\) representation is important because digital devices (such as computers) use the two states on and off, represented by \(0\) and \(1\text{.}\) To distinguish a number in base \(2\) from a number in base \(10\text{,}\) we add a subscript \(2\) to the number in base \(2\text{.}\) For example, we write
\begin{equation*} 1001_2=9\text{.} \end{equation*}
Here, \(1001_2\) is a number in base \(2\text{,}\) and \(9\) is a number in base \(10\text{.}\) Numbers in base \(2\) are also called binary numbers.

Subsection Base \(2\) Expansion

The place values of base \(10\) numbers are powers of \(10\text{.}\) By convention, the least significant digit of a decimal number is on the right, so we write the place values from right to left. For an \(n\)-digit decimal number, that is, a base \(10\) number, the place values are:
\(10^{n-1}\text{,}\) \(10^{n-2}\text{,}\) \(\dots\text{,}\) \(10^4=10\,000\text{,}\) \(10^3=1000\text{,}\) \(10^2=100\text{,}\) \(10^1=10\text{,}\) \(10^0=1\text{.}\)
Similarly the place values of base \(2\) numbers are the powers of two. For an \(n\) digit base \(2\) (or binary) number we have the place values:
\(2^{n-1}\text{,}\) \(2^{n-2}\text{,}\) \(\dots\text{,}\) \(2^4=16\text{,}\) \(2^3=8\text{,}\) \(2^2=4\text{,}\) \(2^1=2\text{,}\) \(2^0=1\text{.}\)
For a binary number
\begin{equation*} a=(r_{n-1}\dots r_2 r_1 r_0)_2 \end{equation*}
where for \(r_i\in\{0,1\}\) we have \(i\in\{0,\dots,n-1\}\) the binary (base \(2\)) expansion
\begin{equation*} a=r_{n-1}\cdot 2^{n-1}+r_{n-2}\cdot 2^{n-2}+\dots+r_1\cdot2+r_0\text{.} \end{equation*}
This immediately gives a method for converting base \(2\) numbers to base \(10\text{.}\)
In the video in Figure 11.2.1 we recap the material covered above and present examples.
Figure 11.2.1. Binary Numbers by Matt Farmer and Stephen Steward
For the remainder of the section we continue considering the conversion of base \(2\) to base \(10\) and also count in base \(2\text{.}\)

Example 11.2.2. Conversion from binary to decimal.

We convert the binary number \(100101_2\) to base \(10\text{.}\) We have
\begin{align*} 100101_2 \amp= 1\cdot 2^5 + 0\cdot 2^4+0\cdot 2^3+1\cdot 2^2+0\cdot 2^1+1\cdot 2^0\\ \amp =32+4+1=37\text{.} \end{align*}
We have found that the decimal representation of the base \(2\) number \(100101_2\) is \(37\text{.}\)
To convert a number written in base \(2\text{,}\) follow these steps:
  • write down the base \(2\) expansion, which consists of the digits of the base \(2\) representation converted to decimal and the place values, which are the powers of \(2\)
  • evaluate this expression to obtain the base \(10\) representation.
In Figure 11.2.3 we give more examples of numbers written in base \(2\text{,}\) their base \(2\) expansions, and their decimal representations.
\(n\) in base \(2\) digits of \(n\) base \(2\) expansion of \(n\) \(n\) in
base \(2\) \(2^3\) \(2^2\) \(2^1\) \(2^0\) base 10
\(0_2\) \(0\) \(0\cdot 1\) \(0\)
\(1_2\) \(1\) \(1\cdot 1\) \(1\)
\(10_2\) \(1\) \(0\) \(1\cdot 2+0\cdot 1\) \(2\)
\(11_2\) \(1\) \(1\) \(1\cdot 2+1\cdot 1\) \(3\)
\(100_2\) \(1\) \(0\) \(0\) \(1\cdot 2^2+0\cdot 2+0\cdot 1\) \(4\)
\(101_2\) \(1\) \(0\) \(1\) \(1\cdot 2^2+0\cdot 2+1\cdot 1\) \(5\)
\(110_2\) \(1\) \(1\) \(0\) \(1\cdot 2^2+1\cdot 2+0\cdot 1\) \(6\)
\(111_2\) \(1\) \(1\) \(1\) \(1\cdot 2^2+1\cdot 2+1\cdot 1\) \(7\)
\(1000_2\) \(1\) \(0\) \(0\) \(0\) \(1\cdot 2^3+0\cdot 2^2+0\cdot 2+0\cdot 0\) \(8\)
\(1001_2\) \(1\) \(0\) \(0\) \(1\) \(1\cdot 2^3+0\cdot 2^2+0\cdot 2+1\cdot 1\) \(9\)
\(1010_2\) \(1\) \(0\) \(1\) \(0\) \(1\cdot 2^3+0\cdot 2^2+1\cdot 2+0\cdot 1\) \(10\)
Figure 11.2.3. Binary (base \(2\)) numbers, their base \(2\) digits, their base \(2\) expansion, and in base \(10\text{.}\) The two symbols used in binary numbers are \(0\) and \(1\text{.}\) Recall that \(2^0=1\) and that \(2^1=2\text{.}\)

Subsection Counting in Base \(2\)

To better understand binary, or base \(2\text{,}\) numbers, we count in that representation.
When we start counting using only the two symbols 0 and 1. As for decimal numbers we start with zero.
\(0_2\text{,}\)
Still with one digit we can also write the number one:
\(1_2\)
So with one digit we were able to count zero and one. As for decimal numbers we add one more digit and obtain:
\(10_2\text{,}\) \(11_2\)
With two digits we have counted to three. As we cannot go further with those two digits, we continue with:
\(100_2\text{,}\) \(101_2\text{,}\) \(110_2\text{,}\) \(111_2\)
With three digits we have counted to seven. Adding one more digit we continue with:
\(1000_2\text{,}\) \(1001_2\text{,}\) \(1010_2\text{,}\) \(1011_2\text{,}\) \(1100_2\text{,}\) \(1101_2\text{,}\) \(1110_2\text{,}\) \(1111_2\)
With 4 digits we have counted from zero to fifteen. By now the pattern is clear and we can keep counting like this indefinitely, adding one more digit when we have exhausted all combinations with the current number of digits.
Note that \(10_2\) is two, \(100_2\) is four, and \(1000_2\) is eight. In Figure 11.2.4 explore these properties and counting in base \(2\) further.
Figure 11.2.4. Counting in base 2 (and base 10). Click on +1, +2, …, +10, … to increment both the both the base 2 and base 10 representation of the number. Click on set to 0 to reset to \(0\text{.}\)
described in detail following the image
A square divided into 2x2 squares, the top-right one has an 1 in it, the bottom-right one has a 0, the two left ones are empty.
Label: Binary Su Doku
Title text: This one is from the Red Belt collection, of ’medium’ difficulty.
This one is from the Red Belt collection of ’medium’ difficulty
Figure 11.2.5. Su Doku by Randall Munroe (https://xkcd.com/74).