Number Systems

Part 1: Number systems and their decimal equivalents

A numbering system or number system is a system that represents numbers in a unique manner using a particular set of symbols. For instance, the decimal system is a number system based on number 10, which is called the base or basis of the system. If n is the base of a number system, then there are n different single symbols in a range of 0 to (n-1) representing numbers in that system. Common number systems are decimal (base 10), binary (base 2), hexadecimal (base 16), and octal (base 8).

A. The decimal number System (Base-10 Number System)

For decimal system, the symbols (or digits) used to represent numbers in the system are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, for example, number 526 or number 526.38.

In the decimal system, number 526 can be expressed as

  \textsf{ \textcolor{red}{526} = (\textcolor{red}{5}\times100) + (\textcolor{red}{2}\times10) + (\textcolor{red}{6}\times1)}

or

\textsf{\textbf{\small{Eq. A.1:}}}
  \textsf{ \textcolor{red}{526} = (\textcolor{red}{5}\times\textcolor{blue}{10}^2) + (\textcolor{red}{2}\times\textcolor{blue}{10}^1) + (\textcolor{red}{6}\times\textcolor{blue}{10}^0) }

Note that the meaning and position of each digit (in red) in number 526 are defined by its respective term on the right hand side (RHS) of Eq. (A.1), whereas the base is in blue color.

Similarly, number 526.38 can be expressed as

  \textsf{ \textcolor{red}{526.38} = (\textcolor{red}{5}\times100) + (\textcolor{red}{2}\times10) + (\textcolor{red}{6}\times1) + (\textcolor{red}{3}\times0.1) + (\textcolor{red}{8}\times0.01)}

or

\textsf{\textbf{\small{Eq. A.2:}}}
  \textsf{ \textcolor{red}{526.38} = (\textcolor{red}{5}\times\textcolor{blue}{10}^2) + (\textcolor{red}{2}\times\textcolor{blue}{10}^1) + (\textcolor{red}{6}\times\textcolor{blue}{10}^0) + (\textcolor{red}{3}\times\textcolor{blue}{10}^{-1}) + (\textcolor{red}{8}\times\textcolor{blue}{10}^{-2}) }

Again, note that the meaning and position of each digit in number 526.38 are defined by its respective term on the RHS of Eq. (A.2), and also note that digits following the decimal point (i.e., 3, 8) have negative sign in its exponent term on the RHS.

B. The binary number system (Base-2 Number System)

For binary system, because the base is 2, only digits 0 and 1 can be used to represent the numbers. Numbers 1101 and 1101.01 are two examples of binary numbers. Similar to Eq. (A.1), but with the base is now 2 instead of 10, binary number 1101 can be written as

\textsf{\textbf{\small{Eq. B.1:}}}
  \textsf{ \textcolor{red}{1101} = (\textcolor{red}{1}\times\textcolor{blue}{2}^3) + (\textcolor{red}{1}\times\textcolor{blue}{2}^2) + (\textcolor{red}{0}\times\textcolor{blue}{2}^1)+ (\textcolor{red}{1}\times\textcolor{blue}{2}^0)}

which in decimal system means

  \textsf{ \textcolor{red}{1101} = (\textcolor{red}{1}\times8) + (\textcolor{red}{1}\times4) + (\textcolor{red}{0}\times2) + (\textcolor{red}{1}\times1)}

or

  \textsf{ (\textcolor{red}{1101})_{\textcolor{blue}{2}} = 8 + 4 + 1 = (13)_{\textcolor{blue}{10}} }

Therefore, binary number 1101 has a value of 13 in the decimal system.

Similar to Eq. A.2, but with the base of 2, binary number 1101.01 can be expressed as

\textsf{\textbf{\small{Eq. B.2:}}}
  \textsf{ \textcolor{red}{1101.01} = (\textcolor{red}{1}\times\textcolor{blue}{2}^3) + (\textcolor{red}{1}\times\textcolor{blue}{2}^2) + (\textcolor{red}{0}\times\textcolor{blue}{2}^1) + (\textcolor{red}{1}\times\textcolor{blue}{2}^0) + (\textcolor{red}{0}\times\textcolor{blue}{2}^{-1}) + (\textcolor{red}{1}\times\textcolor{blue}{2}^{-2}) }

which in the decimal system means

  \textsf{ \textcolor{red}{1101.01} = (\textcolor{red}{1}\times8) + (\textcolor{red}{1}\times4) + (\textcolor{red}{0}\times2) + (\textcolor{red}{1}\times1) + \left(\textcolor{red}{0}\times\frac{1}{2}\right) + \left(\textcolor{red}{1}\times\frac{1}{4}\right) }

or

  \textsf{ \textcolor{red}{1101.01} = (\textcolor{red}{1}\times8) + (\textcolor{red}{1}\times4) + (\textcolor{red}{0}\times2) + (\textcolor{red}{1}\times1) + (\textcolor{red}{0}\times0.5) + (\textcolor{red}{1}\times0.25) }

or

  \textsf{ (\textcolor{red}{1101.01})_{\textcolor{blue}{2}} = 8 + 4 + 1 + 0.25 = (13.25)_{\textcolor{blue}{10}} }

Therefore, binary number 1101.01 has a decimal value of 13.25.

C. The hexadecimal number system (Base-16)

For hexadecimal system, as the base is 16, there are 16 symbols (or digits) to be used to represent the numbers in this system, they are 0 to 9 and then A, B, C, D, E, F (not case-sensitive). Symbols A, B, C, D, E, F are used to replace 10, 11, 12, 13, 14, 15, respectively, because only single digit/symbol can be used. For instance, A1E and A1E.2D are two examples of hexadecimal numbers. Equivalent of A1E in the decimal system is:

  \textsf{ \textcolor{red}{A1E} = (\textcolor{red}{A}\times\textcolor{blue}{16}^2) + (\textcolor{red}{1}\times\textcolor{blue}{16}^1) + (\textcolor{red}{E}\times\textcolor{blue}{16}^0) }

substitute A with 10 and E with 14, we have

  \textsf{ \textcolor{red}{A1E} = (\textcolor{red}{10}\times256) + (\textcolor{red}{1}\times16) + (\textcolor{red}{14}\times1) }

or

  \textsf{ (\textcolor{red}{A1E})_{\textcolor{blue}{16}} = 2560 + 16 + 14 = (2590)_{\textcolor{blue}{10}} }

and the equivalent of A1E.2D in the decimal system is:

  \textsf{ \textcolor{red}{A1E.2D} = (\textcolor{red}{A}\times\textcolor{blue}{16}^2) + (\textcolor{red}{1}\times\textcolor{blue}{16}^1) + (\textcolor{red}{E}\times\textcolor{blue}{16}^0) + (\textcolor{red}{2}\times\textcolor{blue}{16}^{-1}) + (\textcolor{red}{D}\times\textcolor{blue}{16}^{-2}) }

or

  \textsf{ \textcolor{red}{A1E.2D} = (\textcolor{red}{10}\times256) + (\textcolor{red}{1}\times16) + (\textcolor{red}{14}\times1) + \left(\textcolor{red}{2}\times\frac{1}{16}\right) + \left(\textcolor{red}{13}\times\frac{1}{16^2}\right) }

or

  \textsf{ (\textcolor{red}{A1E.2D})_{\textcolor{blue}{16}} = 2560 + 16 + 14 + 0.125 + 0.050781= (2590.175781)_{\textcolor{blue}{10}} }

Therefore, equivalent numbers of A1E and A1E.2D in the decimal system are 2590 and 2590.175781, respectively.

D. The Octal number system (Base-8 number system)

Octal system has the base of 8. There are 8 digits, 0, 1, 2, 3, 4, 5, 6, 7, to be used to represent the numbers in this system. Conversion of an octal number to decimal number is carried out in the same way as for binary or hexadecimal numbers. For instance, two octal numbers 725 and 725.36 can be converted to decimal numbers as follows:

  \renewcommand{\arraystretch}{1.5} \textsf{ \begin{tabular}{l r c l} & 725.36 &= &(\textcolor{red}{7}\times8^2) + (\textcolor{red}{2} \times8^1) + (\textcolor{red}{5}\times8^0) + (\textcolor{red}{3}\times8^{-1})  + (\textcolor{red}{6}\times8^{-2}) \\ &  &= &(\textcolor{red}{7}\times64) + (\textcolor{red}{2} \times8) + (\textcolor{red}{5}\times1) + (\textcolor{red}{3}\times0.125)  + (\textcolor{red}{6}\times0.015625) \\ &  &= & 448 + 16 + 5 + 0.375 + 0.09375 \\ &  &= & 469.46875 \end{tabular} }

  \renewcommand{\arraystretch}{1.5} \textsf{ \begin{tabular}{l r c l} \implies & (725.36)_{\textcolor{blue}{8}} &= &(469.46875)_{\textcolor{blue}{10}} \end{tabular} }

E. Other number systems

Theoretically, any number can be used as a base for a numbering system, and conversion of any number of any base to its equivalent decimal number follows the same method as described by Eqs A.1, A.2 or B.1, B.2 above. For example, using the described approach, quaternary numbers (base 4 numbers) 2103 and 2103.12 are found having decimal values of 147 and 147.375, respectively.

Example

Question: In which system is the number ‘101’ equivalent to a decimal 50?
Answer: Let x be the unknown base and x > 0, similar to Eq. A.1, we can write

  \renewcommand{\arraystretch}{1.5} \textsf{ \begin{tabular}{l r c l} & \textcolor{red}{1}x^2 + \textcolor{red}{0} \textsf{x}^1 + \textcolor{red}{1} \textsf{x}^0 &= &50 \\ \therefore & x^2 + 1 &= &50 \\ \therefore & x^2 &= &49 \\ \therefore & x &= &7 \\ \end{tabular} }

The base is 7, thus, the system is septenary system.


Notes:

  • For fractional numbers, the fractional part could be infinite, so, if you want to limit the number of digits after the decimal point, a cut-off may be needed. In such cases, the number and its equivalent decimal value may not be exactly equal.
  • Conversion of a decimal number to another number system is covered in Number Systems, Part 2
  • In general, a number can be converted to any other number system by using the decimal system as an intermediate step. A Python code for converting a number of any base to another number system can be found here. In this code, the base is only between 2 and 16, but users can expand it for any base greater than 16, if a system of symbols is defined for such a base accordingly.

Number Systems – Part 2: Decimal Numbers

Number Systems – Part 3: Binary Numbers & Base-4, Base-8, Base-16 Number Systems