Skip to main content
\(\newcommand{\doubler}[1]{2#1} \newcommand{\binary}{\texttt} \newcommand{\hex}{\texttt} \newcommand{\octal}{\texttt} \newcommand{\prog}{\texttt} \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section2.2Mathematical Equivalence of Binary and Decimal

We have seen in the previous section that binary digits are the natural way to show the states of switches within the computer and that hexadecimal is a convenient way to show the states of up to four switches with only one character. Now we explore some of the mathematical properties of the binary number system and show that it is numerically equivalent to the more familiar decimal (base 10) number system. Showing the mathematical equivalence of the hexadecimal and decimal number systems is left as an exercise for you at the end of this section.

By convention, we use a positional notation when writing numbers. For example, in the decimal number system, the integer 123 is taken to mean \begin{equation}1 \times 100 + 2 \times 10 + 3 \times 1\label{eq-123a}\tag{2.2.1}\end{equation} or \begin{equation}1 \times 10^2 + 2 \times 10^1 + 3 \times 10^0\label{eq-123b}\tag{2.2.2}\end{equation} The right-most digit (3 in Equations (2.2.1) and (2.2.2)) is the least significant digit because it “counts” the least in the total value of this number. The left-most digit (1 in this example) is the most significant digit because it “counts” the most in the total value of this number.

The base or radix of the decimal number system is ten. There are ten symbols for representing the digits: 0, 1,…, 9. Moving a digit one place to the left increases its value by a factor of ten, and moving it one place to the right decreases its value by a factor of ten. The positional notation generalizes to any radix, \(r\text{:}\) \begin{equation} d_{n-1} \times r^{n-1} + d_{n-2} \times r^{n-2} + \ldots d_{1} \times r^{1} + d_{0} \times r^{0}\label{eq-radix}\tag{2.2.3}\end{equation} where there are \(n\) digits in the number and each \(d_{i} = 0, 1, \ldots, r-1\text{.}\) The radix in the binary number system is 2, so there are only two symbols for representing the digits: \(d_{i} = \binary{0}, \binary{1}\text{.}\) We can specialize Equation (2.2.3) for the binary number system as \begin{equation}d_{n-1} \times 2^{n-1} + d_{n-2} \times 2^{n-2} + \ldots d_{1} \times 2^{1} + d_{0} \times 2^{0} \label{eq-radix2}\tag{2.2.4}\end{equation} where there are \(n\) digits in the number and each \(d_{i} = \binary{0}, \binary{1}\text{.}\)

Although we are considering only integers at this point, Equation (2.2.3) does, of course, generalize to fractional values. Simply continue the exponents of the radix, \(r\text{,}\) on to negative values, that is, \(r^{n-1}, r^{n-2},\ldots, r^{1}, r^{0}, r^{-1}, r^{-2},\ldots\) . This will be covered in detail in Chapter 16.

It is very simple to convert from binary to decimal:

Subsection2.2.1Exercises

1

Referring to Equation (2.2.3), what are the values of \(r\text{,}\) \(n\) and each \(d_{i}\) for the decimal number \(29458254\text{?}\) The hexadecimal number \(\hex{29458254}\text{?}\)

Answer
2

Convert the eight-digit binary number \(\binary{1010} \; \binary{0101}\) to decimal.

Answer
3

Convert the following 8-bit binary numbers to decimal by hand:

  1. \(\binary{1010} \; \binary{1010} \)

  2. \(\binary{0101} \; \binary{0101} \)

  3. \(\binary{1111} \; \binary{0000} \)

  4. \(\binary{0000} \; \binary{1111} \)

  5. \(\binary{1000} \; \binary{0000} \)

  6. \(\binary{0110} \; \binary{0011} \)

  7. \(\binary{0111} \; \binary{1011} \)

  8. \(\binary{1111} \; \binary{1111} \)

Answer
4

Convert the following 16-bit binary numbers to decimal by hand:

  1. \(\binary{1010} \; \binary{1011} \; \binary{1110} \; \binary{1101}\)

  2. \(\binary{0001} \; \binary{0011} \; \binary{0011} \; \binary{0100}\)

  3. \(\binary{1111} \; \binary{1110} \; \binary{1101} \; \binary{1100}\)

  4. \(\binary{0000} \; \binary{0111} \; \binary{1101} \; \binary{1111}\)

  5. \(\binary{1000} \; \binary{0000} \; \binary{0000} \; \binary{0000}\)

  6. \(\binary{0000} \; \binary{0100} \; \binary{0000} \; \binary{0000}\)

  7. \(\binary{0111} \; \binary{1011} \; \binary{1010} \; \binary{1010}\)

  8. \(\binary{0011} \; \binary{0000} \; \binary{0011} \; \binary{1001}\)

Answer
5

Develop an algorithm to convert hexadecimal to decimal, and then convert the following 16-bit numbers to decimal by hand:

  1. \(\hex{a000}\)

  2. \(\hex{ffff}\)

  3. \(\hex{0400}\)

  4. \(\hex{1111}\)

  5. \(\hex{8888}\)

  6. \(\hex{0190}\)

  7. \(\hex{abcd}\)

  8. \(\hex{5555}\)

Hint Answer