anna university DLD 1052233110

Number Systems and Codes

SA
StudyAI
AI-generated study notes
· Published Updated

From the dld curriculum

TL;DR

Number systems are ways to represent quantities, with binary, octal, decimal, and hexadecimal being the most common in digital logic. Codes are specific patterns of bits used to represent data, like BCD for decimal digits or ASCII for characters. Understanding these systems and codes is fundamental for working with digital circuits and computer data.

1. The Mental Model

Think of number systems as different languages for counting. Just like you can say "one" in English or "uno" in Spanish, you can represent the quantity '1' in different number systems. Codes are like secret handshakes or specific abbreviations that computers use to represent information efficiently.

2. The Core Material

Understanding Number Systems

Close-up view of wooden numbers arranged on a black surface, ideal for educational themes.
Photo by Roman Friptuleac on Pexels

A number system is defined by its base (or radix), which tells you how many unique digits it uses. Each digit's position has a "weight" that's a power of the base.

  • Decimal (Base-10): This is what we use every day. It has 10 digits (0-9). Each position is a power of 10 (e.g., $10^0$, $10^1$, $10^2$).

    • Example: $123_{10} = 1 \times 10^2 + 2 \times 10^1 + 3 \times 10^0$
  • Binary (Base-2): The fundamental system for digital electronics. It uses only two digits: 0 and 1 (bits). Each position is a power of 2.

    • Example: $1011_2 = 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0 = 8 + 0 + 2 + 1 = 11_{10}$
  • Octal (Base-8): Uses 8 digits (0-7). Each position is a power of 8. It's often used as a shorthand for binary because 3 binary digits (bits) can represent one octal digit ($2^3 = 8$).

    • Example: $27_8 = 2 \times 8^1 + 7 \times 8^0 = 16 + 7 = 23_{10}$
  • Hexadecimal (Base-16): Uses 16 "digits": 0-9 and A-F (where A=10, B=11, ..., F=15). Each position is a power of 16. It's also a shorthand for binary, as 4 bits can represent one hex digit ($2^4 = 16$).

    • Example: $1A_{16} = 1 \times 16^1 + 10 \times 16^0 = 16 + 10 = 26_{10}$

Conversions Between Number Systems

Close-up view of wooden numbers arranged on a black surface, ideal for educational themes.
Photo by Roman Friptuleac on Pexels

You'll often need to convert numbers between these systems.

  • Any Base to Decimal: Multiply each digit by its positional weight (power of the base) and sum the results. (See examples above).

  • Decimal to Any Base: Use repeated division by the target base, keeping track of the remainders. The remainders, read from bottom to top, form the new number.

  • Binary to Octal/Hexadecimal: Group binary digits. For octal, group in threes from the right. For hexadecimal, group in fours from the right. Convert each group to its equivalent octal/hex digit.

  • Octal/Hexadecimal to Binary: Convert each octal/hex digit into its 3-bit (for octal) or 4-bit (for hex) binary equivalent.

Binary Arithmetic

Close-up of a vintage Diehl mechanical calculator with visible numeric keys and brown casing.
Photo by Markus Spiske on Pexels

Basic arithmetic operations (addition, subtraction) work similarly to decimal, but with only 0s and 1s.

  • Binary Addition:
    • 0 + 0 = 0
    • 0 + 1 = 1
    • 1 + 0 = 1
    • 1 + 1 = 0 (carry 1)
    • 1 + 1 + 1 = 1 (carry 1)

Binary Codes

Blurred person in front of a digital code projection creating a tech-inspired abstract vibe.
Photo by Ron Lach on Pexels

Codes are specific ways to represent information using binary digits.

  • Binary Coded Decimal (BCD): Each decimal digit (0-9) is represented by its 4-bit binary equivalent. This is useful for displaying decimal numbers directly, like in digital clocks.

    • Example: $52_{10}$ in BCD is $0101 \ 0010$. (Note: $52_{10}$ in pure binary is $110100_2$).
  • Gray Code: A special binary code where only one bit changes between successive numbers. This is useful in applications like rotary encoders to avoid errors when transitioning between states.

  • ASCII (American Standard Code for Information Interchange): A 7-bit (or 8-bit extended) code that represents characters (letters, numbers, symbols) used in text. This is how your computer stores and displays text.

  • Error Detection Codes (Parity): A simple method to detect errors during data transmission. A parity bit is added to a data word to make the total number of 1s either always even (even parity) or always odd (odd parity). If the received data doesn't match the parity rule, an error is detected.

Here's how different number systems relate:

graph TD
    A["Number Systems"] --> B["Decimal (Base-10)"]
    A --> C["Binary (Base-2)"]
    A --> D["Octal (Base-8)"]
    A --> E["Hexadecimal (Base-16)"]

    C --> C1["Binary Arithmetic"]
    C --> C2["Binary Codes"]

    C2 --> C2a["BCD (Binary Coded Decimal)"]
    C2 --> C2b["Gray Code"]
    C2 --> C2c["ASCII (Text Chars)"]
    C2 --> C2d["Error Detection (Parity)"]

    B -- "Common Use" --> A
    C -- "Digital Circuits" --> A
    D -- "Shorthand for Binary" --> C
    E -- "Shorthand for Binary" --> C

3. Worked Example

Let's convert a decimal number to binary, then to hexadecimal, and finally check its ASCII representation.

Problem: Convert $45_{10}$ to binary and hexadecimal. Then, consider what the character 'A' is in ASCII.

Step 1: Decimal to Binary (for $45_{10}$)
We use repeated division by 2:

  • $45 \div 2 = 22$ remainder $1$
  • $22 \div 2 = 11$ remainder $0$
  • $11 \div 2 = 5$ remainder $1$
  • $5 \div 2 = 2$ remainder $1$
  • $2 \div 2 = 1$ remainder $0$
  • $1 \div 2 = 0$ remainder $1$

Reading the remainders from bottom to top: $45_{10} = 101101_2$.

Step 2: Binary to Hexadecimal (for $101101_2$)
Group the binary digits in fours from the right. Add leading zeros if needed:

$0010 \ 1101_2$

  • The first group $0010_2$ is $2_{16}$.
  • The second group $1101_2$ is $D_{16}$ (since $D_{16} = 13_{10} = 8+4+0+1$).

So, $45_{10} = 101101_2 = 2D_{16}$.

Step 3: ASCII for 'A'
From an ASCII table (which you'd typically look up), the character 'A' is represented by the decimal value $65_{10}$.
To find its binary representation:

  • $65 \div 2 = 32$ remainder $1$
  • $32 \div 2 = 16$ remainder $0$
  • $16 \div 2 = 8$ remainder $0$
  • $8 \div 2 = 4$ remainder $0$
  • $4 \div 2 = 2$ remainder $0$
  • $2 \div 2 = 1$ remainder $0$
  • $1 \div 2 = 0$ remainder $1$

So, 'A' in ASCII is $1000001_2$.

4. Key Takeaways

  • Number systems differ by their base, determining the number of unique digits and positional weights.
  • Binary (base-2) is the foundation of digital logic, using only 0s and 1s.
  • Octal (base-8) and Hexadecimal (base-16) are convenient shorthands for representing binary numbers.
  • Conversions between bases are essential skills, especially decimal to binary/hex and vice-versa.
  • Binary arithmetic follows rules similar to decimal, with specific carry conditions for addition.
  • Codes like BCD, Gray, and ASCII provide standardized ways to represent different types of data using binary.
  • Parity bits are a simple form of error detection to ensure data integrity.

Common Mistakes to Avoid:
* Confusing the number of bits required for octal (3 bits) versus hexadecimal (4 bits).
* Forgetting to read remainders from bottom-to-top when converting from decimal.
* Mixing up BCD with pure binary; BCD represents each decimal digit separately, pure binary represents the whole number.
* Incorrectly calculating positional weights, especially with higher powers.

5. Now Try It

Convert the hexadecimal number $3F_{16}$ to its decimal equivalent. Then, convert that decimal result into BCD. Your success will be showing the step-by-step conversion for both parts, ending with the correct BCD representation.

Frequently asked about Number Systems and Codes

Number systems are ways to represent quantities, with binary, octal, decimal, and hexadecimal being the most common in digital logic. Codes are specific patterns of bits used to represent data, like BCD for decimal digits or ASCII for characters. Read the full notes above for the details.

Number Systems and Codes is a core topic in dld. Most exam papers test it via a mix of definitions, worked examples, and applied problems. The notes above cover the high-yield sub-topics, common pitfalls, and the kind of questions examiners typically set.

Yes — every note in the StudyAI Campus Hub is free to read in full, right here on this page, with no account needed. If you clone the plan into your own dashboard, the free plan shows a preview of each note there; Basic and above unlock the full notes in your dashboard, along with practice quizzes, flashcards and offline study. You can always come back here to read the complete note for free.

Study this next


Get the full dld curriculum

Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.

Save this course free