1.2 Understanding Binary and Decimal Conversions

Aug 28, 2024

Lecture Notes: Binary to Decimal and Decimal to Binary Conversion

Key Concepts

  • Binary to Decimal Conversion

    • Example: Convert 101 in base 2 to base 10.
      • Number positions: 0, 1, 2
      • Calculation: 1 * 2^2 + 0 * 2^1 + 1 * 2^0
      • 4 (from 2^2) + 0 (from 0 * 2^1) + 1 (from 2^0)
      • Result: 5 in base 10
    • Example: Convert 1010101 in base 2 to decimal.
      • Number positions: 3, 2, 1, 0, -1, -2, -3
      • Whole number calculation: 8 + 0 + 2 + 0 + 0.5 + 0 + 0.125
      • Result: 10.625 in base 10
  • Decimal to Binary Conversion

    • Convert 10.625 in base 10 to binary
      • Whole number part: 10
      • Fractional part: 0.625
      • Divide whole number by 2, track remainders for binary:
        • 10 / 2 = 5 R0
        • 5 / 2 = 2 R1
        • 2 / 2 = 1 R0
        • 1 / 2 = 0 R1
      • Binary whole: 1010
      • Multiply fractional by 2, track whole parts:
        • 0.625 * 2 = 1.25 (Whole 1)
        • 0.25 * 2 = 0.5 (Whole 0)
        • 0.5 * 2 = 1.0 (Whole 1)
      • Binary fractional: .101
      • Result: 1010.101 base 2
  • Iterative Technique for Base Conversion

    • Convert decimal to base 3 example:
      • Convert 15 base 10 to base 3
      • Divide by 3, note remainders:
        • 15 / 3 = 5 R0
        • 5 / 3 = 1 R2
        • 1 / 3 = 0 R1
      • Result: 120 base 3
  • Special Cases for Base Conversion

    • Binary to Octal (base 8): Group binary digits in sets of three.
    • Binary to Hexadecimal (base 16): Group binary digits in sets of four.
    • Example: Convert binary 1010110 to octal and hexadecimal.
    • Hexadecimal digits: 0-9 and A-F (A=10, B=11,..., F=15).

Practice Problems

  • Convert Decimal to Binary

    • Problem: Convert 13.25 base 10 to binary.
    • Options:
      • 1101.01
      • 1100.01
      • 1011.11
      • 1101.101
  • Convert Decimal to Hexadecimal

    • Problem: Convert 77 base 10 to hexadecimal.
    • Options:
      • 3F
      • 4D
      • 21
      • 37

Summary

  • Techniques for converting between number systems: binary, octal, hexadecimal.
  • Importance of understanding positional notation and the iterative technique.
  • Application to computing and digital systems.