Section 11.2 Binary Representation
Before we move on to presenting numbers with arbitrary base \(b\) where \(b\) is a natural number greater than \(1\text{,}\) we consider one more special case. One of the most common bases other than base \(10\) is base \(2\text{.}\) While base \(10\) numbers are written with the ten symbols \(0\text{,}\) \(1\text{,}\) \(2\text{,}\) \(3\text{,}\) \(4\text{,}\) \(5\text{,}\) \(6\text{,}\) \(7\text{,}\) \(8\text{,}\) and \(9\) numbers in base \(2\) are written using the two symbols
Base \(2\) representation is particular of interest because digital devices (such as computers) work with the two states on and off, which are represented by \(0\) and \(1\text{.}\) To distinguish numbers in base \(2\) representation from numbers in base \(10\) representation we add a subscript \(2\) to the number in base \(2\) representation. For example, we write
where we interpret \(1001_2\) as a number in base \(2\) representation and \(9\) as a number in base \(10\) representation. Numbers in base \(2\) representation are also called binary numbers.
Subsection 11.2.1 Base \(2\) Expansion
The values of the places of base \(10\) numbers are the powers of \(10\text{.}\) As before we write these from right to left because (by convention) the least significant digit of numbers in decimal representation is on the right. For an \(n\) digit decimal (that is, bas \(10\)) number we have the place values:
\(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
where for \(r_i\in\{0,1\}\) we have \(i\in\{0,\dots,n-1\}\) the binary (base \(2\)) expansion
This immediately yields 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.
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
We have found that the decimal representation of the base \(2\) number \(100101_2\) is \(37\text{.}\)
In Figure 11.2.3 we give more examples of numbers in base \(2\text{,}\) their base \(2\) expansion, and the number in decimal representation.
\(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\) |
So to convert a number in base \(2\) representation
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.
Try yourself.
Checkpoint 11.2.4. Convert from binary to decimal.
Give the expanded base \(2\) form of \(111011_{2}\text{.}\)
\(\cdot 2^6 +\) \(\cdot 2^5 +\) \(\cdot 2^4 +\) \(\cdot 2^3 +\) \(\cdot 2^2 +\) \(\cdot 2+\) \(\cdot 1\)
Give \(111011_{2}\) in decimal representation.
Subsection 11.2.2 Counting in Base \(2\)
For a better understanding of binary (or base \(2\)) numbers, we consider counting in that representation.
When we start counting using only the two symbols 0 and 1. As in the case of 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 in the case of 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.
Considering the numbers above we see that \(10_2\) is two, \(100_2\) is four, and \(1000_2\) is eight.
In Checkpoint 11.2.5 apply the pattern described above to count in base \(2\text{.}\)
Checkpoint 11.2.5. Count in base \(2\).
Count in base 2
In the first column enter the numbers in base \(2\text{.}\) Recall that the characters used to represent base \(2\) numbers are:
In the other columns enter the values for the digits of the base \(2\) expansions.
For your convenience the last number in each row is the corresponding decimal number.
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 0\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 1\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 2\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 3\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 4\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 5\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 6\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 7\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 8\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 9\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 10\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 11\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 12\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 13\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 14\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 15\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 16\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 17\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 18\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 19\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 20\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 21\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 22\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 23\)
\({}_{2} =\)
\(\cdot 2^{4} +\)
\(\cdot 2^{3} +\)
\(\cdot 2^{2} +\)
\(\cdot 2^{1} +\)
\(\cdot 2^{0} = 24\)
0
\(0\)
\(0\)
\(0\)
\(0\)
\(0\)
1
\(0\)
\(0\)
\(0\)
\(0\)
\(1\)
10
\(0\)
\(0\)
\(0\)
\(1\)
\(0\)
11
\(0\)
\(0\)
\(0\)
\(1\)
\(1\)
100
\(0\)
\(0\)
\(1\)
\(0\)
\(0\)
101
\(0\)
\(0\)
\(1\)
\(0\)
\(1\)
110
\(0\)
\(0\)
\(1\)
\(1\)
\(0\)
111
\(0\)
\(0\)
\(1\)
\(1\)
\(1\)
1000
\(0\)
\(1\)
\(0\)
\(0\)
\(0\)
1001
\(0\)
\(1\)
\(0\)
\(0\)
\(1\)
1010
\(0\)
\(1\)
\(0\)
\(1\)
\(0\)
1011
\(0\)
\(1\)
\(0\)
\(1\)
\(1\)
1100
\(0\)
\(1\)
\(1\)
\(0\)
\(0\)
1101
\(0\)
\(1\)
\(1\)
\(0\)
\(1\)
1110
\(0\)
\(1\)
\(1\)
\(1\)
\(0\)
1111
\(0\)
\(1\)
\(1\)
\(1\)
\(1\)
10000
\(1\)
\(0\)
\(0\)
\(0\)
\(0\)
10001
\(1\)
\(0\)
\(0\)
\(0\)
\(1\)
10010
\(1\)
\(0\)
\(0\)
\(1\)
\(0\)
10011
\(1\)
\(0\)
\(0\)
\(1\)
\(1\)
10100
\(1\)
\(0\)
\(1\)
\(0\)
\(0\)
10101
\(1\)
\(0\)
\(1\)
\(0\)
\(1\)
10110
\(1\)
\(0\)
\(1\)
\(1\)
\(0\)
10111
\(1\)
\(0\)
\(1\)
\(1\)
\(1\)
11000
\(1\)
\(1\)
\(0\)
\(0\)
\(0\)

This one is from the Red Belt collection of 'medium' difficulty
https://xkcd.com/74
).