Convert between positive denary and positive binary

Resources | Subject Notes | Computer Science

Data Representation: Converting Between Decimal and Binary

This section covers the conversion of numbers between the decimal (base-10) and binary (base-2) systems. Understanding these conversions is fundamental to understanding how computers store and process information.

Decimal to Binary Conversion

Converting a decimal number to binary involves repeatedly dividing the decimal number by 2 and noting the remainders. The remainders, read in reverse order, form the binary equivalent.

Here's a step-by-step process:

  1. Divide the decimal number by 2.
  2. Note the remainder (0 or 1). This is a binary digit (bit).
  3. Divide the quotient from the previous step by 2.
  4. Continue this process until the quotient is 0.
  5. The binary number is the sequence of remainders read in reverse order.

Example: Convert the decimal number 25 to binary.

Division Quotient Remainder
$25 \div 2$ $12$ $1$
$12 \div 2$ $6$ $0$
$6 \div 2$ $3$ $0$
$3 \div 2$ $1$ $1$
$1 \div 2$ $0$ $1$

Reading the remainders in reverse order gives the binary equivalent: 11001.

Therefore, the decimal number 25 is equal to the binary number 11001.

Binary to Decimal Conversion

Converting a binary number to decimal involves multiplying each binary digit by 2 raised to the power of its position (starting from the rightmost digit as position 0) and then summing the results.

Here's the process:

  1. Identify the position of each binary digit (from right to left, starting at 0).
  2. Multiply each binary digit by $2^{\text{position}}$.
  3. Sum the results of these multiplications.

Example: Convert the binary number 11001 to decimal.

Binary Digit Position $2^{\text{Position}}$ Product
1 4 $2^4 = 16$ $1 \times 16 = 16$
0 3 $2^3 = 8$ $0 \times 8 = 0$
0 2 $2^2 = 4$ $0 \times 4 = 0$
1 1 $2^1 = 2$ $1 \times 2 = 2$
1 0 $2^0 = 1$ $1 \times 1 = 1$

Summing the products: $16 + 0 + 0 + 2 + 1 = 19$.

Therefore, the binary number 11001 is equal to the decimal number 19.

Summary

The conversion between decimal and binary is a fundamental skill in computer science. Understanding these conversions is crucial for comprehending how data is represented and manipulated within a computer.