In-Depth Notes on Number Systems, Operations, and Codes in Digital Electronics

Decimal Numbers

  • Definition: The decimal number system is a weighted number system with a radix (base) of 10, using digits 0 through 9.

  • Column Weights: Each digit place represents a power of ten, increasing from right to left:

    • Whole numbers: 100,101,102,103,…10^0, 10^1, 10^2, 10^3, …
    • Fractional numbers: 10−1,10−2,10−3,…10^{-1}, 10^{-2}, 10^{-3}, …
  • Example: Representing 568.23 in weighted sums:

    • 5×102+6×101+8×100+2×10−1+3×10−25 \times 10^2 + 6 \times 10^1 + 8 \times 10^0 + 2 \times 10^{-1} + 3 \times 10^{-2}
    • Calculation: 500+60+8+0.2+0.03=568.23500 + 60 + 8 + 0.2 + 0.03 = 568.23

Binary Numbers

  • Definition: The binary number system is used in digital systems, having a radix (base) of 2 with digits 0 and 1.

  • Column Weights: Powers of two increase from right to left:

    • Whole numbers: 20,21,22,…2^0, 2^1, 2^2, …
    • Fractional numbers: 2−1,2−2,…2^{-1}, 2^{-2}, …
  • Counting Up To: With nn bits, the highest number is 2n−12^n - 1.

  • Example with 6 bits: Maximum = 26−1=632^6 - 1 = 63 (0 to 63)

Binary Weighting Structure
  • Right-most bit = LSB (Least Significant Bit)
  • Left-most bit = MSB (Most Significant Bit)
  • For fractional binary, weights are negative powers of 2.

Binary to Decimal Conversion

  • Procedure: Add values of bits equal to 1 and ignore bits that are 0.

  • Example: Binary number 1101101:

    • 1×26+1×25+0×24+1×23+1×22+0×21+1×20=64+32+0+8+4+0+1=1091 \times 2^6 + 1 \times 2^5 + 0 \times 2^4 + 1 \times 2^3 + 1 \times 2^2 + 0 \times 2^1 + 1 \times 2^0 = 64 + 32 + 0 + 8 + 4 + 0 + 1 = 109
  • Fractional Example: Binary number 0.1011:

    • 1×2−1+0×2−2+1×2−3+1×2−4=0.5+0+0.125+0.0625=0.68751 \times 2^{-1} + 0 \times 2^{-2} + 1 \times 2^{-3} + 1 \times 2^{-4} = 0.5 + 0 + 0.125 + 0.0625 = 0.6875

Decimal to Binary Conversion

  1. Sum of Weights Method: Identify powers of 2 that sum to the decimal number.
    • Example: Convert 25: 16+8+1→1100116 + 8 + 1 \rightarrow 11001
  2. Repeated Division by 2: Continually divide by 2 and track remainders.
  • Example: Decimal 19 to binary:
    1. 19 / 2 = 9 remainder 1
    2. 9 / 2 = 4 remainder 1
    3. 4 / 2 = 2 remainder 0
    4. 2 / 2 = 1 remainder 0
    5. 1 / 2 = 0 remainder 1
    • Thus, 19 = 10011

Binary Arithmetic Operations

  1. Binary Addition Rules:

    • 0+0=00+0=0, 0+1=10+1=1, 1+0=11+0=1, 1+1=101+1=10 (carry 1 to next bit)
    • Example: 11+11=11011 + 11 = 110 (3 + 3 = 6)
  2. Binary Subtraction Rules:

    • Requires borrowing like decimal subtraction.
    • Example: 11−01=1011 - 01 = 10 (3 - 1 = 2)
  3. Binary Multiplication:

    • Similar to decimal multiplication; involves partial products.
    • Example: 11×11=100111 \times 11 = 1001 (3*3=9)
  4. Binary Division:

    • Follows the same principles as decimal division.

Complements in Binary Numbers

  • 1's Complement: Invert all bits.
  • 2's Complement: Add 1 to the 1's complement.
    • Example: 1's complement of 10110010 is 01001101; adding 1 makes it 01001110.

Signed Binary Numbers

  • Sign Bit: Left-most bit indicates the sign (0 = positive, 1 = negative).
    • Sign-Magnitude Form: Sign bit + magnitude.
    • Example: +81 as 01010001, -25 as 10011001.
  • 1's Complement Form: Positive same as sign-magnitude, negative as 1's complement.
    • Example: +25 as 00011001, -25 as 11100110 (1's complement).
  • 2's Complement Form: Positive same as elsewhere, negative as 2's complement of positive.
    • Example: +25 as 00110001, -25 as 11001111 (2's complement).

Hexadecimal Number System

  • Definition: Base 16 system using digits 0-9 and letters A-F.
  • Conversion:
    • Binary to Hexadecimal: Groups of 4 bits.
    • Hexadecimal to Binary: Reverse process.

ASCII and Digital Codes

  • ASCII: American Standard Code for Information interchange, using 7-bit binary.
  • Example: Character 'A' is 1000001.
  • Gray Code: A binary numeral system where two successive values differ in only one bit.