Looks like you're stuck. Need a hand?

Share This Tutorial

Views 37

Converting Between Binary and Decimal

Author Zak |  Date  |  Category Computer Science
Calculating reading time...
Loading difficulty...
Back Back

Converting Between Binary and Decimal

Understanding Binary

Binary is a base-2 number system, meaning it only uses two digits: 0 and 1. Each position in a binary number represents a power of 2, starting from the rightmost digit as 20, then 21, 22, and so on.

Converting Binary to Decimal

  1. Identify the place values: Write down the powers of 2 for each digit in the binary number, starting from the rightmost digit.

    1011 (binary) = 2^3 2^2 2^1 2^0

  2. Multiply the digit by its place value: Multiply each binary digit by its corresponding power of 2.

    1 * 2^3 = 8 0 * 2^2 = 0 1 * 2^1 = 2 1 * 2^0 = 1

  3. Sum the results: Add the results from step 2.

    8 + 0 + 2 + 1 = 11

Therefore, 1011 (binary) is equal to 11 (decimal).

Converting Decimal to Binary

  1. Find the largest power of 2 less than the decimal number: Identify the largest power of 2 that is smaller than the decimal number.

    Example: Decimal number 13 Largest power of 2 less than 13 is 2^3 = 8

  2. Subtract the power of 2 from the decimal number: Subtract the largest power of 2 from the decimal number.

    13 - 8 = 5

  3. Repeat steps 1 and 2 with the remaining value: Find the largest power of 2 less than the remaining value (5 in this case).

    Largest power of 2 less than 5 is 2^2 = 4 5 - 4 = 1

  4. Continue repeating steps 1 and 2 until the remaining value is 0:

    Largest power of 2 less than 1 is 2^0 = 1 1 - 1 = 0

  5. Write a '1' for each power of 2 used and a '0' for unused powers: In our example, we used 23, 22, and 20.

    13 (decimal) = 1101 (binary)

Example:

Binary to Decimal:

Decimal to Binary: