Number System and Codes: Complete Exam Notes for Computer Organization and Architecture

Hello, my dear students! Welcome to Chapter Two of Computer Organization and Architecture (COA). In this lesson, we will study Number Systems and Codes. This chapter is very important because everything inside a computer — numbers, letters, images, sounds — is represented using only 0s and 1s. So understanding how numbers work in different systems is the key to understanding how computers process data. Are you ready? Let’s go step by step!

1. Data Types in Digital Computers

Before we jump into number systems, let me ask you a simple question: What kind of data does a computer store? Think about it for a moment. You type numbers, letters, and symbols on your keyboard. But the computer does not understand any of these directly. It only understands 0 and 1 — which we call the binary form.

So, all data in any form is represented using 0 and 1. This binary information is stored in memory or processor registers. Now, the registers can contain two types of information:

  • Data — numbers and other binary-coded information that the computer processes
  • Control information — a bit or a group of bits used to specify the sequence of command signals

The data types found in the registers of digital computers include:

  1. Numbers — used in arithmetic computations (addition, subtraction, etc.)
  2. Letters of the alphabet — used in data processing (text, names, etc.)
  3. Other discrete symbols — used for specific purposes (like $, %, @, etc.)

Let me give you a simple example. When you type the letter “A” on your keyboard, the computer stores it as 01000001 in binary. When you type the number 5, the computer stores it as 00000101. Everything — every number, every letter, every symbol — gets converted to binary. That is why we need to study number systems carefully!

📝 Important Points to Remember:
• Computer only understands binary (0 and 1)
• Binary information is stored in memory or processor registers
• Registers contain either data or control information
• Data types: Numbers, Letters, and Other discrete symbols

📝 Practice Questions — Data Types

Q1 (MCQ): The binary information stored in processor registers can be classified as:

A) Only data    B) Only control information    C) Data or control information    D) Neither data nor control information

Answer: C) Data or control information
Explanation: According to the PDF, registers contain either data (numbers and other binary-coded information) or control information (a bit or group of bits used to specify the sequence of command signals). Both types coexist in a computer’s registers.

Q2 (MCQ): Control information in a digital computer is:

A) Numbers used in arithmetic computation    B) Letters of the alphabet used in data processing    C) A bit or group of bits specifying the sequence of command signals    D) Binary representation of decimal numbers only

Answer: C) A bit or group of bits specifying the sequence of command signals
Explanation: Control information is specifically defined as bits that control the sequence of command signals — it tells the computer WHAT to do and WHEN. Options A and B describe data, not control information.

Q3 (List and Explain): List the three data types found in the registers of digital computers and briefly explain each.

Answer:
1. Numbers: Used in arithmetic computations such as addition, subtraction, multiplication, and division. Examples: 15, 3.14, -7.
2. Letters of the alphabet: Used in data processing tasks like text editing, name storage, and document creation. Examples: A, B, C, z.
3. Other discrete symbols: Used for specific purposes depending on the application. Examples: $, %, @, #, &.

2. Number Systems

Now let me ask you: What is a number system? A number system is simply the way of representing numbers. Different number systems use different bases (also called radices). The most common number systems are four: Decimal, Binary, Octal, and Hexadecimal.

Let me explain each one in detail with examples. Pay close attention because conversion questions come in almost every exam!

2.1 Decimal Number System (Base 10)

The decimal number system is important because it is universally used to represent quantities outside a digital system — meaning this is the number system you and I use every day! It uses digits from 0 to 9 and has a base of 10.

Each position in a decimal number has a place value based on powers of 10. Let me show you with an example from your PDF:

Example: Break down the number 10264

\[ (10264)_{10} = (1 \times 10^4) + (0 \times 10^3) + (2 \times 10^2) + (6 \times 10^1) + (4 \times 10^0) \]
\[ = 1 \times 10000 + 0 \times 1000 + 2 \times 100 + 6 \times 10 + 4 \times 1 \]
\[ = 10000 + 0 + 200 + 60 + 4 = \mathbf{10264} \]

This expansion shows how each digit is multiplied by its place value. The rightmost digit has the lowest power (100 = 1) and the leftmost digit has the highest power. This same concept applies to ALL number systems — we just change the base!

Place Values of 10264 in DecimalPosition: 4 3 2 1 0 Digit: 1 0 2 6 4 Power: 10⁴ 10³ 10² 10¹ 10⁰ Value: 10000 1000 100 10 1 Result: 10000 + 0 + 200 + 60 + 4 = 10264

2.2 Binary Number System (Base 2)

The binary number system is the most important number system for computers. It is based on the concept of ON or OFF. Its two digits are denoted by 0 and 1, and each digit is called a bit. The binary number system has a base of 2.

Let me show you how decimal numbers 0 through 9 are represented in binary:

Decimal0123456789
Binary01101110010111011110001001

Now, let me ask you: can you see the pattern here? Each time we reach the maximum digit (1 in binary), we carry over to the next position. Just like in decimal, when we reach 9 we go to 10.

Examples from the PDF:

  • Decimal 14 = (1110)2
  • Decimal 19 = (10011)2
  • Decimal 50 = (110010)2
📝 Important Point: In binary, each digit is called a bit. The rightmost bit is called the Least Significant Bit (LSB) and the leftmost bit is called the Most Significant Bit (MSB). This is a very common exam term!

2.3 Octal Number System (Base 8)

The octal number system uses exactly eight symbols: 0, 1, 2, 3, 4, 5, 6, and 7. It has a base of 8. One very important fact about octal numbers is that each octal digit has a unique 3-bit binary representation. This makes conversion between octal and binary very easy — we will see that later.

Octal numbers can be converted to decimal values by multiplying each digit with its place value (powers of 8) and then adding the results.

Examples from the PDF:

  • Decimal 135 = (207)8
  • Decimal 215 = (327)8

Let me verify the first one for you:

\[ (207)_8 = 2 \times 8^2 + 0 \times 8^1 + 7 \times 8^0 = 2 \times 64 + 0 + 7 \times 1 = 128 + 7 = 135 \]

2.4 Hexadecimal Number System (Base 16)

The hexadecimal number system spans from 0 to 9 and then continues with A to F. The letters A, B, C, D, E, and F represent the decimal values 10, 11, 12, 13, 14, and 15 respectively. It has a base of 16.

Hexadecimal numbers are more convenient for people to recognize and interpret than the long strings of binary numbers. For example, instead of writing 11111111 in binary, we can simply write FF in hexadecimal — much shorter and easier to read!

Examples from the PDF:

  • Decimal 255 = (FF)16
  • Decimal 1096 = (448)16
  • Decimal 4090 = (FFA)16

Let me verify the first example:

\[ (FF)_{16} = F \times 16^1 + F \times 16^0 = 15 \times 16 + 15 \times 1 = 240 + 15 = 255 \]
📝 Complete Number System Summary Table:
Number SystemBaseDigits UsedExample
Binary20, 1(1101)2
Octal80, 1, 2, 3, 4, 5, 6, 7(207)8
Decimal100, 1, 2, 3, 4, 5, 6, 7, 8, 9(135)10
Hexadecimal160-9, A, B, C, D, E, F(FF)16

📝 Practice Questions — Number Systems

Q1 (MCQ): The number system with base 8 that uses digits 0 through 7 is called:

See also  Introduction to Computer Organization and Architecture: Complete Exam Notes

A) Binary    B) Decimal    C) Octal    D) Hexadecimal

Answer: C) Octal
Explanation: The octal number system has a base of 8 and uses exactly eight symbols: 0, 1, 2, 3, 4, 5, 6, and 7. Binary has base 2, decimal has base 10, and hexadecimal has base 16.

Q2 (MCQ): In the hexadecimal system, what decimal value does the digit ‘D’ represent?

A) 12    B) 13    C) 14    D) 15

Answer: B) 13
Explanation: In hexadecimal: A=10, B=11, C=12, D=13, E=14, F=15. So D represents 13. Don’t confuse D with 12 (that’s C) or 14 (that’s E)!

Q3 (MCQ): Each octal digit corresponds to how many binary digits?

A) 2 bits    B) 3 bits    C) 4 bits    D) 8 bits

Answer: B) 3 bits
Explanation: According to the PDF, “Each octal digit has a unique 3-bit binary representation.” This is because 23 = 8, which matches the base of the octal system. Similarly, each hexadecimal digit corresponds to 4 binary digits (since 24 = 16).

Q4 (Fill in the Blank): The rightmost bit of a binary number is called the _______ and the leftmost bit is called the _______.

Answer: Least Significant Bit (LSB), Most Significant Bit (MSB)
Explanation: The rightmost bit has the lowest place value (20) and is called the Least Significant Bit (LSB). The leftmost bit has the highest place value and is called the Most Significant Bit (MSB).

3. Conversion of Number Systems

This is the most exam-tested section of this chapter! You must be able to convert between any two number systems. Let me teach you each conversion method with detailed examples. I will go slow so you understand every step.

3.1 Conversion from Binary to Decimal

The binary number system has a base 2, so the position weights are based on the power of 2. To convert a binary number to decimal, multiply each bit by its place value (2 raised to the position number) and add all the results.

Example 1: Convert (100111)2 to decimal

\[ (100111)_2 = 1 \times 2^5 + 0 \times 2^4 + 0 \times 2^3 + 1 \times 2^2 + 1 \times 2^1 + 1 \times 2^0 \]
\[ = 32 + 0 + 0 + 4 + 2 + 1 = \mathbf{39} \]
Step-by-Step BreakdownPosition: 5 4 3 2 1 0 Bit: 1 0 0 1 1 1 Power: 2⁵ 2⁴ 2³ 2² 2¹ 2⁰ Value: 32 16 8 4 2 1 Multiply: 32 + 0 + 0 + 4 + 2 + 1 = 39

Example 2: Convert (0.1010)2 to decimal

For fractional binary numbers, the powers of 2 become negative after the decimal point:

\[ (0.1010)_2 = 0 \times 2^0 + 1 \times 2^{-1} + 0 \times 2^{-2} + 1 \times 2^{-3} + 0 \times 2^{-4} \]
\[ = 0 + \frac{1}{2} + 0 + \frac{1}{8} + 0 = 0.5 + 0.125 = \mathbf{0.625} \]

Example 3: Convert (1101.1010)2 to decimal

\[ (1101.1010)_2 = 1 \times 2^3 + 1 \times 2^2 + 0 \times 2^1 + 1 \times 2^0 + 1 \times 2^{-1} + 0 \times 2^{-2} + 1 \times 2^{-3} + 0 \times 2^{-4} \]
\[ = 8 + 4 + 0 + 1 + 0.5 + 0 + 0.125 + 0 = \mathbf{13.625} \]
🎯 Exam Tip: For fractional binary numbers, remember that the first digit after the point has position -1 (value = 0.5), the second has position -2 (value = 0.25), the third has position -3 (value = 0.125), and so on. Don’t forget to include the integer part!

3.2 Hexadecimal to Binary Conversion

This conversion is very easy! Each hexadecimal digit converts to exactly 4 binary digits. Just replace each hex digit with its 4-bit binary equivalent. Let me show you the reference table first:

Hex Digit01234567
Binary (4-bit)00000001001000110100010101100111
Hex Digit89ABCDEF
Binary (4-bit)10001001101010111100110111101111

Example: Convert (FF)16 to binary

\[ (FF)_{16} = \underbrace{F}_{1111} \underbrace{F}_{1111} = (11111111)_2 \]

Example: Convert (448)16 to binary

\[ (448)_{16} = \underbrace{4}_{0100} \underbrace{4}_{0100} \underbrace{8}_{1000} = (010001001000)_2 \]

3.3 Octal to Binary Conversion

Similarly, each octal digit converts to exactly 3 binary digits. Replace each octal digit with its 3-bit binary equivalent.

Octal Digit01234567
Binary (3-bit)000001010011100101110111

Example: Convert (207)8 to binary

\[ (207)_8 = \underbrace{2}_{010} \underbrace{0}_{000} \underbrace{7}_{111} = (010000111)_2 \]

3.4 Octal → Binary → Hexadecimal Conversion

Sometimes you need to convert from octal to hexadecimal. The easiest way is to go through binary as a middle step: Octal → Binary → Hexadecimal. Here is the procedure:

  1. Convert octal to binary (replace each octal digit with 3 bits)
  2. Group the binary bits in groups of 4 (starting from the right)
  3. Convert each 4-bit group to its hexadecimal equivalent

Example: Convert (327)8 to hexadecimal

Step 1: Octal to Binary(327)₈ = 011 010 111Step 2: Group into 4 bits (from right)011 010 111 → 0110 1011 (pad with 0 on the left if needed)Step 3: Convert each 4-bit group to hex0110 = 6 1011 = BAnswer: (6B)₁₆

3.5 Hexadecimal to Octal Conversion

This is the reverse process: Hexadecimal → Binary → Octal.

  1. Convert hexadecimal to binary (replace each hex digit with 4 bits)
  2. Group the binary bits in groups of 3 (starting from the right)
  3. Convert each 3-bit group to its octal equivalent

Example: Convert (FFA)16 to octal

Step 1: Hexadecimal to Binary(FFA)₁₆ = 1111 1111 1010Step 2: Group into 3 bits (from right)1111 1111 1010 → 1 111 111 110 10 → 001 111 111 110 100 (pad with 0s on the left)Step 3: Convert each 3-bit group to octal001 = 1 111 = 7 111 = 7 110 = 6 100 = 4Answer: (17764)₈
📝 Important Conversion Shortcuts:
Hex ↔ Binary: Each hex digit = 4 binary bits
Octal ↔ Binary: Each octal digit = 3 binary bits
Hex ↔ Octal: Go through binary as a bridge (Hex → Binary → Octal or Octal → Binary → Hex)
Any base → Decimal: Multiply each digit by (base)position and add
Decimal → Binary: Repeatedly divide by 2, collect remainders bottom-up
⚠️ Common Mistake: When grouping binary bits, ALWAYS group from the right side (from LSB). If the leftmost group has fewer bits, pad with zeros on the LEFT side. Never pad on the right — that changes the value!

📝 Practice Questions — Number Conversions

Q1 (MCQ): Convert (1101.101)2 to decimal:

A) 13.5    B) 13.625    C) 11.625    D) 14.5

Answer: B) 13.625
Explanation:
Integer part: 1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13
Fractional part: 1×2⁻¹ + 0×2⁻² + 1×2⁻³ = 0.5 + 0 + 0.125 = 0.625
Total = 13 + 0.625 = 13.625

Q2 (MCQ): The hexadecimal number (A3)16 is equal to which binary number?

A) 10100011    B) 10100001    C) 10100010    D) 11100011

Answer: A) 10100011
Explanation: A = 1010 in binary, 3 = 0011 in binary. So (A3)₁₆ = 1010 0011 = 10100011. Remember, each hex digit converts to exactly 4 binary bits!

Q3 (MCQ): To convert octal (563)8 to hexadecimal, the correct intermediate binary form is:

A) 101 110 011    B) 0101 0110 0011    C) 101 011 001    D) 0101 1100 11

Answer: A) 101 110 011
Explanation: The FIRST step in octal → hex conversion is octal → binary (each octal digit becomes 3 bits): 5=101, 6=110, 3=011. So the intermediate binary is 101 110 011. Then we regroup into 4-bit groups for hex: 0101 1100 11 → pad → 0101 1100 1100 → (16C)₁₆. Option B is the 4-bit grouped version (not the direct intermediate), option C has wrong bits, option D is incorrect padding.

Q4 (Workout): Convert (0.1101)2 to decimal.

Answer:
\[ (0.1101)_2 = 1 \times 2^{-1} + 1 \times 2^{-2} + 0 \times 2^{-3} + 1 \times 2^{-4} \]
\[ = \frac{1}{2} + \frac{1}{4} + 0 + \frac{1}{16} = 0.5 + 0.25 + 0.0625 = \mathbf{0.8125} \]

Q5 (Workout): Convert (B2F)16 to octal.

Answer:
Step 1: Hex to Binary
B = 1011, 2 = 0010, F = 1111
(B2F)₁₆ = 1011 0010 1111

Step 2: Group into 3 bits from right
101 100 101 111

Step 3: Convert each group to octal
101 = 5, 100 = 4, 101 = 5, 111 = 7
Answer: (5457)8

4. Binary Arithmetic

Now, let me ask you something: Since computers only understand binary, how do they perform calculations? The answer is — they use binary arithmetic. The machine performs all computations using binary numbers. Let me explain the three basic operations: addition, subtraction, and multiplication.

4.1 Binary Addition

Binary addition operates by the same rules as decimal addition. The only difference is that we only have two digits (0 and 1). A carry to the next higher order position occurs when the sum is decimal 2 (which is binary 10). You must memorize these four rules:

That last rule is very important! It occurs when both binary digits are 1 AND there is a carry from the previous lower position. So we are adding three 1s. Let me show you the examples from the PDF:

Example 1: 6 + 7 = 13

Carry: 1 1 1 1 1 0 (6 in binary) + 1 1 1 (7 in binary) ——- 1 1 0 1 (13 in binary)Verification: 1101 = 8+4+0+1 = 13 ✓

Let me walk you through column by column from right to left:

  • Column 0 (rightmost): 0 + 1 = 1 (no carry)
  • Column 1: 1 + 1 = 0 with carry 1
  • Column 2: 1 + 1 + 1 (carry) = 1 with carry 1 ← this uses the fifth rule!
  • Column 3: 0 + 0 + 1 (carry) = 1

Example 2: 6 + 5 = 11

Carry: 1 1 1 1 1 0 (6 in binary) + 1 0 1 (5 in binary) ——- 1 0 1 1 (11 in binary)Verification: 1011 = 8+0+2+1 = 11 ✓

4.2 Binary Subtraction

Binary subtraction uses “borrowing” — just like decimal subtraction. If you try to subtract 1 from 0, you must borrow from the next higher column. In binary, a borrow from the next column is worth 2 (which is 10 in binary).

📝 Binary Subtraction Rules (Must Memorize):
0 – 0 = 0
1 – 0 = 1
1 – 1 = 0
0 – 1 = 1 with a borrow of 1 from the next position

Example 1: 28 – 26 = 2

1 1 1 0 0 (28 in binary) – 1 1 0 1 0 (26 in binary) ——— 0 0 0 1 0 (2 in binary)Verification: 00010 = 2 ✓

Let me walk through this column by column from right to left:

  • Column 0: 0 – 0 = 0
  • Column 1: 0 – 1 → borrow needed! Borrow from column 2 (which becomes 0). Now 10 – 1 = 1
  • Column 2: Was 1, now 0 (after borrow). 0 – 0 = 0
  • Column 3: 1 – 1 = 0
  • Column 4: 1 – 1 = 0

Example 2: 45 – 7 = 38

1 0 1 1 0 1 (45 in binary) – 0 0 0 1 1 1 (7 in binary) ———– 1 0 0 1 1 0 (38 in binary)Verification: 100110 = 32+0+0+4+2+0 = 38 ✓

4.3 Binary Multiplication

Binary multiplication is actually quite simple because you are only ever multiplying by 0 or 1. It involves a series of “shift and add” steps, identical to long multiplication in decimal. The rules are very straightforward:

📝 Binary Multiplication Rules:
0 × 0 = 0
0 × 1 = 0
1 × 0 = 0
1 × 1 = 1

Notice that multiplying by 0 always gives 0, and multiplying by 1 gives the original number. Let me show you how the “shift and add” method works:

Example: Multiply 110 × 101

1 1 0 (6 in decimal) × 1 0 1 (5 in decimal) ——- 1 1 0 (110 × 1, no shift) 0 0 0 (110 × 0, shift left by 1) 1 1 0 (110 × 1, shift left by 2) ——— 1 1 1 1 0 (30 in decimal)Verification: 6 × 5 = 30 ✓
🎯 Exam Tip: In binary multiplication, always remember to shift left for each subsequent row. The first partial product has no shift, the second shifts left by 1 position, the third shifts left by 2 positions, and so on. Then add all partial products using binary addition (with carries!).

📝 Practice Questions — Binary Arithmetic

Q1 (MCQ): Perform binary addition: 1011 + 1101 = ?

A) 10100    B) 11000    C) 11100    D) 10110

Answer: B) 11000
Explanation:
Carries: 1 1 1 1 1 0 1 1 + 1 1 0 1 ——- 1 1 0 0 0Column 0: 1+1 = 0 carry 1 Column 1: 1+0+1 = 0 carry 1 Column 2: 0+1+1 = 0 carry 1 Column 3: 1+1+1 = 1 carry 1 Column 4: 0+0+1 = 111000 = 16+8+0+0+0 = 24 Verification: 11+13 = 24 ✓

Q2 (MCQ): In binary subtraction, when we compute 0 – 1, the result is:

A) 0 with no borrow    B) 1 with borrow 1    C) 1 with no borrow    D) 0 with borrow 1

Answer: B) 1 with borrow 1
Explanation: According to the binary subtraction rules, 0 – 1 = 1 with a borrow of 1 from the next position. This is because we borrow 2 (which is 10 in binary), and 10 – 1 = 1. The borrow of 1 is passed to the next higher column.

Q3 (MCQ): The binary addition rule for 1 + 1 + 1 (with carry from previous position) gives:

A) 1 with carry 0    B) 0 with carry 1    C) 1 with carry 1    D) 0 with carry 0

Answer: C) 1 with carry 1
Explanation: When adding three 1s (two digits plus a carry), the sum is 3 in decimal, which is 11 in binary. So we write 1 and carry 1 to the next position. This is the fifth rule of binary addition that students often forget!

Q4 (Workout): Perform binary subtraction: 11010 – 01101

Answer:
1 1 0 1 0 (26 in decimal) – 0 1 1 0 1 (13 in decimal) ———– 0 1 1 0 1 (13 in decimal)Column 0: 0-1 → borrow → 10-1 = 1 Column 1: 0-0=0 (after borrow, was 0, borrowed → need borrow again from col 2) Column 2: 0-1 → borrow → 10-1 = 1 Column 3: 0-1 → borrow → 10-1 = 1 Column 4: 0-0=0 (after borrow)Verification: 26 – 13 = 13 ✓ 01101 = 8+4+0+1+0 = 13 ✓

Q5 (Workout): Perform binary multiplication: 111 × 110

Answer:
1 1 1 (7 in decimal) × 1 1 0 (6 in decimal) ——- 0 0 0 (111 × 0, no shift) 1 1 1 (111 × 1, shift left by 1) 1 1 1 (111 × 1, shift left by 2) ——— 1 0 1 0 1 0 (42 in decimal)Verification: 7 × 6 = 42 ✓ 101010 = 32+0+8+0+2+0 = 42 ✓

5. Complements

Now we come to a very important topic. Let me ask you: How does a computer perform subtraction if it only knows how to add? The answer is — by using complements! Complements are used in digital systems to perform logical manipulation, and most importantly, to simplify subtraction by converting it into addition.

The binary number system contains two types of complements:

  • 1’s complement
  • 2’s complement

Let me explain each one carefully.

5.1 1’s Complement

The 1’s complement of a binary number is very easy to find. You simply invert all the bits — change every 0 to 1, and every 1 to 0. That’s it! There is no complex calculation involved.

📝 1’s Complement Rule:
To find the 1’s complement of a binary number, invert all bits:
• Change every 0 → 1
• Change every 1 → 0

Example 1: Find the 1’s complement of (0101)

Original: 0 1 0 1 1’s Comp: 1 0 1 0Simply flip each bit!

Example 2: Find the 1’s complement of (1101)

Original: 1 1 0 1 1’s Comp: 0 0 1 0

5.1.1 Signed Binary Representation

Now, this is a very important concept. In signed binary representation, the leftmost bit is used to indicate the sign of the number:

  • 0 = positive number
  • 1 = negative number

For example, using a 5-bit representation:

+15 = (01111)₂ ← leftmost bit is 0 (positive) -15 = (11111)₂ ← leftmost bit is 1 (negative)
⚠️ Important: When a number is stored using signed binary representation, the leftmost bit is reserved for the sign. This means in a 4-bit signed representation, only 3 bits are available for the magnitude. In a 5-bit signed representation, only 4 bits are available for the magnitude. Always pay attention to how many bits are being used!

5.2 2’s Complement

The 2’s complement is the most widely used complement in digital systems. It is used for representing negative numbers and for performing subtraction through addition. Here is how to find it:

📝 2’s Complement Rule (Two Steps):
Step 1: Find the 1’s complement (invert all bits)
Step 2: Add 1 to the 1’s complement result

In short: 2’s complement = 1’s complement + 1

Example 1: Find the 2’s complement of (11010)

Step 1: Find 1’s complement Original: 1 1 0 1 0 1’s Comp: 0 0 1 0 1Step 2: Add 1 0 0 1 0 1 + 1 ——— 0 0 1 1 0Answer: 2’s complement of (11010) = (00110)

Example 2: Find the 2’s complement of (0101)

Step 1: Find 1’s complement Original: 0 1 0 1 1’s Comp: 1 0 1 0Step 2: Add 1 1 0 1 0 + 1 ——— 1 0 1 1Answer: 2’s complement of (0101) = (1011)
🎯 Exam Tip: The 2’s complement is the most important complement in this course. Here is why:
• It is used to represent negative numbers in computers
• It allows subtraction to be performed as addition (A – B = A + 2’s complement of B)
• It has no ambiguous representation of zero (unlike 1’s complement which has +0 and -0)
• Exam questions frequently ask: “Find the 2’s complement” or “Use 2’s complement to subtract”
⚠️ Common Mistake: Many students forget to add 1 after finding the 1’s complement. Remember: 2’s complement = 1’s complement + 1. Not just the 1’s complement alone! Always do both steps.

📝 Practice Questions — Complements

Q1 (MCQ): The 1’s complement of the binary number (10110) is:

A) 01001    B) 01010    C) 10101    D) 11001

Answer: A) 01001
Explanation: 1’s complement = invert all bits.
Original: 1 0 1 1 0
1’s Comp: 0 1 0 0 1
Simply flip every bit: 1→0, 0→1, 1→0, 1→0, 0→1 = 01001

Q2 (MCQ): The 2’s complement of (0110) is:

A) 1001    B) 1010    C) 1000    D) 1101


Q3 (MCQ): In signed binary representation, a 5-bit number (10110) represents:

A) +22    B) -6    C) -22    D) +6

Answer: B) -6
Explanation: The leftmost bit is 1, which means the number is negative. The remaining 4 bits (0110) represent the magnitude in 2’s complement form. To find the actual value: find the 2’s complement of 0110 = 1001 + 1 = 1010 = 6. So the number is -6.

Note: If interpreted as unsigned, 10110 = 22. But in signed representation with the leftmost bit as sign, it is -6.

Q4 (MCQ): To obtain the 2’s complement of a binary number, we:

A) Invert all bits only    B) Add 1 to the original number    C) Invert all bits and then add 1    D) Subtract 1 from the original number

Answer: C) Invert all bits and then add 1
Explanation: The standard procedure for 2’s complement is: Step 1 — Find the 1’s complement (invert all bits), Step 2 — Add 1 to the result. Option A gives only 1’s complement. Option B is incorrect. Option D has no relationship to 2’s complement.

Q5 (Workout): Find the 1’s complement and 2’s complement of (101101).

Answer:
1’s Complement: Invert all bits
Original: 1 0 1 1 0 1 1’s Comp: 0 1 0 0 1 0
1’s complement = (010010)

2’s Complement: Add 1 to 1’s complement
0 1 0 0 1 0 + 1 ———– 0 1 0 0 1 1
2’s complement = (010011)

Q6 (Workout): Find the 2’s complement of (10000) and verify your answer.

Answer:
Step 1: 1’s complement of 10000 = 01111
Step 2: Add 1:
0 1 1 1 1 + 1 ———– 1 0 0 0 0
2’s complement of (10000) = (10000)

Interesting fact: The 2’s complement of a number that is a pure power of 2 (like 10000 = 16) gives back the same number! This is a special case. In signed representation, 10000 in a 5-bit system represents -16 (the most negative number possible with 5 bits).

Q7 (List and Explain): List the two types of complements in the binary number system and explain how each is obtained.

Answer:
1. 1’s Complement:
• Method: Invert all bits of the binary number (change 0 to 1 and 1 to 0)
• Example: 1’s complement of (0101) = (1010)
• Use: Used as an intermediate step to find 2’s complement; also used in some subtraction algorithms

2. 2’s Complement:
• Method: First find the 1’s complement, then add 1 to the result
• Example: 2’s complement of (0101) = 1010 + 1 = (1011)
• Use: Most widely used complement in digital systems; used to represent negative numbers and to perform subtraction through addition

6. Comprehensive Exam Review Questions

Excellent work, my dear students! You have completed the entire chapter on Number Systems and Codes. Now let me test your understanding with some harder mixed questions. These are the type of questions that appear in actual Ethiopian university exams. Try to answer before clicking “Show Answer”!

🔴 Hard Exam Questions — Mixed Topics

Q1 (MCQ): A binary number has 6 bits. What is the maximum decimal number it can represent?

A) 32    B) 63    C) 64    D) 31

Answer: B) 63
Explanation: With n bits, the maximum unsigned number is 2n – 1. For 6 bits: 26 – 1 = 64 – 1 = 63. The largest 6-bit binary number is (111111)2 = 63. Option C (64) would require 7 bits (1000000).

Q2 (MCQ): The binary subtraction 10100 – 01111 is equal to:

A) 00101    B) 01001    C) 00111    D) 00011

Answer: A) 00101
Explanation:
1 0 1 0 0 (20) – 0 1 1 1 1 (15) ———– 0 0 1 0 1 (5)Column 0: 0-1 → borrow → 10-1=1 Column 1: 0-1 → borrow → 10-1=1 Column 2: 0-1 → borrow → 10-1=1 Column 3: 0-1 → borrow → 10-1=1 Column 4: 0-0=0 (after borrow)
Verification: 20 – 15 = 5, and 00101 = 4 + 0 + 1 = 5 ✓

Q3 (MCQ): If the 2’s complement of a number is (1101), then the original number (before complement) is:

A) 0010    B) 0011    C) 1101    D) 1011

Answer: B) 0011
Explanation: To find the original number from its 2’s complement, we take the 2’s complement again!
2’s complement of (1101):
Step 1: 1’s complement = 0010
Step 2: 0010 + 1 = 0011
So the original number is (0011). This is a useful property: the 2’s complement of the 2’s complement gives back the original number.

Q4 (MCQ): Which of the following hexadecimal numbers is equal to the octal number (345)8?

A) E3    B) D4    C) E5    D) C5

Answer: C) E5
Explanation:
Step 1: Octal to Binary: 3=011, 4=100, 5=101
(345)8 = 011 100 101
Step 2: Group into 4 bits from right: 1110 0101
Step 3: Convert to hex: 1110 = E, 0101 = 5
Answer: (E5)16

Q5 (Fill in the Blank): In signed binary representation, the leftmost bit is 0 for a _______ number and 1 for a _______ number.

Answer: positive, negative
Explanation: In signed binary representation, 0 in the leftmost position denotes a positive number and 1 denotes a negative number. For example, in 5-bit representation: +15 = (01111) and -15 = (11111).

Q6 (Workout): Convert (175)8 to hexadecimal.

Answer:
Step 1: Octal to Binary
1 = 001, 7 = 111, 5 = 101
(175)8 = 001 111 101

Step 2: Group into 4 bits from right
001 111 101 → 0111 1101

Step 3: Convert to hex
0111 = 7, 1101 = D
Answer: (7D)16

Verification: (175)8 = 1×64 + 7×8 + 5×1 = 64 + 56 + 5 = 125
(7D)16 = 7×16 + 13×1 = 112 + 13 = 125 ✓

Q7 (Workout): Perform binary addition: 11011 + 10111 + 00111

Answer:
First add 11011 + 10111:
Carries: 1 1 1 1 1 1 1 0 1 1 + 1 0 1 1 1 ——— 1 1 0 0 1 0
Then add 110010 + 00111:
Carries: 1 1 1 0 0 1 1 0 0 1 0 + 0 0 1 1 1 ———– 1 1 1 0 0 1
Answer: (111001)2
Verification: 27 + 23 + 7 = 57, and 111001 = 32+16+8+0+0+1 = 57 ✓

Q8 (Workout): Find the 2’s complement of (1011001).

Answer:
Step 1: 1’s complement — invert all bits
Original: 1 0 1 1 0 0 1 1’s Comp: 0 1 0 0 1 1 0
Step 2: Add 1
0 1 0 0 1 1 0 + 1 ————— 0 1 0 0 1 1 1
2’s complement = (0100111)

Q9 (Write/Explain): Why are complements used in digital systems? Explain with reference to the two types of binary complements.

Answer:
Complements are used in digital systems to perform logical manipulation. The most important use is to simplify subtraction by converting it into addition. Since computers are designed to efficiently perform addition, using complements allows subtraction (A – B) to be computed as A + (complement of B).

The two types of binary complements are:
1. 1’s Complement: Obtained by inverting all bits of the binary number. It can be used for subtraction but has the disadvantage of having two representations of zero (+0 and -0).
2. 2’s Complement: Obtained by finding the 1’s complement and then adding 1. It is the most widely used complement because it has only one representation of zero and simplifies hardware design for arithmetic operations.

Q10 (MCQ): The binary equivalent of the hexadecimal number (2B6)16 is:

A) 01010110110    B) 001010110110    C) 0010110110    D) 1010110110

Answer: B) 001010110110
Explanation: Each hex digit converts to 4 binary bits:
2 = 0010, B = 1011, 6 = 0110
(2B6)16 = 0010 1011 0110 = 001010110110
Count the bits: 3 × 4 = 12 bits. Option B has exactly 12 bits and matches. Option A has 11 bits (missing leading 0), option C has 10 bits, option D has 10 bits.

7. Final Summary — What to Remember for Your Exam

Wonderful job, students! You have completed the entire Number Systems and Codes chapter. Here is your quick revision checklist — carry this to the exam hall!

📘 Quick Revision Checklist:

1. Data Types: Numbers, Letters, Other symbols — all stored as binary (0 and 1)

2. Number Systems — Bases and Digits:
• Binary: Base 2, digits {0, 1}
• Octal: Base 8, digits {0,1,2,3,4,5,6,7}
• Decimal: Base 10, digits {0,1,2,3,4,5,6,7,8,9}
• Hexadecimal: Base 16, digits {0-9, A,B,C,D,E,F} where A=10, B=11, …, F=15

3. Key Terms:
LSB = Least Significant Bit (rightmost)
MSB = Most Significant Bit (leftmost)

4. Conversion Methods:
• Any base → Decimal: Multiply each digit by baseposition, add results
• Hex ↔ Binary: Each hex digit = 4 bits
• Octal ↔ Binary: Each octal digit = 3 bits
• Hex ↔ Octal: Go through binary as bridge
• Fractional binary: Negative powers after decimal point (-1, -2, -3, …)

5. Binary Arithmetic Rules:
• Addition: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (0 carry 1), 1+1+1=11 (1 carry 1)
• Subtraction: 0-0=0, 1-0=1, 1-1=0, 0-1=1 (borrow 1)
• Multiplication: 0×anything=0, 1×1=1, use shift and add

6. Complements:
1’s complement = Invert all bits
2’s complement = 1’s complement + 1
• Signed representation: Leftmost bit 0 = positive, 1 = negative
• 2’s complement of 2’s complement = original number

I hope this detailed lesson helped you understand Number Systems and Codes clearly. Practice all the conversion problems and complement calculations again and again — speed and accuracy come with practice. Good luck in your exam, my dear students! You can do it! 💪

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top