Convert Binary and Decimal Numbers

Table of Contents

Binary to Decimal Conversion

The decimal number system (base 10) uses the digits \(0\) to \(9\), while the binary number system (base 2) uses only the digits \(0\) and \(1\).

In the decimal system, each digit represents a power of \(10\). For example:

\[ 149 = 1 \times 10^2 + 4 \times 10^1 + 9 \times 10^0 \]

Similarly, each digit in a binary number represents a power of \(2\).

Convert the binary number \(10010101_2\) to decimal:

\[ \begin{aligned} 10010101_2 &= 1\times2^7 + 0\times2^6 + 0\times2^5 + 1\times2^4 \\ &\quad + 0\times2^3 + 1\times2^2 + 0\times2^1 + 1\times2^0 \\ &= 128 + 16 + 4 + 1 \\ &= 149 \end{aligned} \]

Therefore, the binary number \(10010101_2\) is equal to \(149_{10}\).

Decimal to Binary Conversion

To convert a decimal number into binary, repeatedly divide the number by \(2\) and record the remainders. The binary number is obtained by reading the remainders from bottom to top.

Example: Convert the decimal number \(123\) to binary.

\[ \begin{aligned} 123 \div 2 &= 61 \quad r = 1 \\ 61 \div 2 &= 30 \quad r = 1 \\ 30 \div 2 &= 15 \quad r = 0 \\ 15 \div 2 &= 7 \quad r = 1 \\ 7 \div 2 &= 3 \quad r = 1 \\ 3 \div 2 &= 1 \quad r = 1 \\ 1 \div 2 &= 0 \quad r = 1 \end{aligned} \]

Reading the remainders from bottom to top gives:

\[ 123_{10} = 1111011_2 \]

Verification:

\[ 1111011_2 = 1\times2^6 + 1\times2^5 + 1\times2^4 + 1\times2^3 + 0\times2^2 + 1\times2^1 + 1\times2^0 = 123 \]

You may also use this online tool: Decimal to Binary Converter.

Exercises

A. Convert the binary numbers to decimal

  1. \(11_2\)
  2. \(101_2\)
  3. \(1111_2\)
  4. \(110111011_2\)
  5. \(1111100011110011_2\)

B. Convert the decimal numbers to binary

  1. \(7\)
  2. \(13\)
  3. \(128\)
  4. \(1678\)
  5. \(12359\)

Answers

A. Binary to Decimal

\[ 11_2 = 1\times2^1 + 1\times2^0 = 3 \] \[ 101_2 = 1\times2^2 + 1 = 5 \] \[ 1111_2 = 8 + 4 + 2 + 1 = 15 \] \[ 110111011_2 = 443 \] \[ 1111100011110011_2 = 63731 \]

B. Decimal to Binary

\[ 7_{10} = 111_2 \] \[ 13_{10} = 1101_2 \] \[ 128_{10} = 10000000_2 \] \[ 1678_{10} = 11010001110_2 \] \[ 12359_{10} = 11000001000111_2 \]