Number System and Conversion Boolean Logic
Computer Science – Grade XI
Unit 2: Number System, Conversion and Boolean Logic
Topics covered: 2.1 Number Systems · 2.2 Number Conversion · 2.3 Binary Arithmetic and Complements · 2.4 Boolean Algebra and Logic Gates
2.1 Number Systems
A number system is a systematic way of representing numbers using a fixed set of symbols (digits) and rules.
2.1.1 Types of Number Systems
Non-positional number system
Each symbol has a fixed value, no matter where it appears. Values are found by simple addition or subtraction of symbols.
Example: Roman numerals (I, V, X, L, C, D, M). In XXX, every X means 10.
Positional number system
The value of a digit depends on the digit itself, its position, and the base (radix) of the system.
Base / Radix: the total number of different digits used by the system.
| System | Base | Digits used | Example |
|---|---|---|---|
| Decimal | 10 | 0 – 9 | (789)₁₀ |
| Binary | 2 | 0, 1 | (1101)₂ |
| Octal | 8 | 0 – 7 | (572)₈ |
| Hexadecimal | 16 | 0 – 9, A – F | (3AF)₁₆ |
In hexadecimal, A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
Weight of a position: for base b, the digit at position n has weight bⁿ. Positions to the left of the point are 0, 1, 2, … and positions to the right are −1, −2, −3, …
| Base | Weights (right to left from the point) |
|---|---|
| Binary | … 32 16 8 4 2 1 . ½ ¼ ⅛ … |
| Octal | … 512 64 8 1 . ⅛ 1/64 … |
| Hexadecimal | … 4096 256 16 1 . 1/16 1/256 … |
2.1.2 Some Basic Terms
- Bit: one binary digit (0 or 1)
- Nibble: 4 bits
- Byte: 8 bits
- MSB (Most Significant Bit): the leftmost bit; it has the highest weight
- LSB (Least Significant Bit): the rightmost bit; it has the lowest weight
2.1.3 Why Does a Computer Use Binary?
- Electronic circuits have two stable states: ON (high voltage = 1) and OFF (low voltage = 0).
- Two-state circuits are simple, cheap and reliable, and are less affected by electrical noise.
- True/false logic maps directly onto 1 and 0.
2.1.4 Why Octal and Hexadecimal?
Long binary numbers are hard to read and copy. Octal and hexadecimal are short forms of binary:
- 1 octal digit = 3 binary bits
- 1 hexadecimal digit = 4 binary bits
2.1.5 Equivalent Values (0 – 15)
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
2.2 Number Conversion
2.2.1 Summary of Methods
| Conversion | Method |
|---|---|
| Decimal → Binary / Octal / Hexadecimal | Divide repeatedly by 2 / 8 / 16; read the remainders from bottom to top |
| Binary / Octal / Hexadecimal → Decimal | Multiply each digit by its weight and add (expansion method) |
| Binary ↔ Octal | 4 2 1 method (groups of 3 bits) |
| Binary ↔ Hexadecimal | 8 4 2 1 method (groups of 4 bits) |
| Octal ↔ Hexadecimal | Convert through binary |
2.2.2 Decimal to Binary, Octal and Hexadecimal
Steps
- Divide the number by the base and write the remainder beside it.
- Divide the quotient again by the base. Repeat until the quotient becomes 0.
- Read the remainders from bottom to top.
(a) Decimal to Binary: (45)₁₀ = (?)₂
| Base | Number | Remainder |
|---|---|---|
| 2 | 45 | 1 |
| 2 | 22 | 0 |
| 2 | 11 | 1 |
| 2 | 5 | 1 |
| 2 | 2 | 0 |
| 2 | 1 | 1 |
| 0 |
Reading the remainders from bottom to top (↑): 1 0 1 1 0 1
∴ (45)₁₀ = (101101)₂
(b) Decimal to Octal: (500)₁₀ = (?)₈
| Base | Number | Remainder |
|---|---|---|
| 8 | 500 | 4 |
| 8 | 62 | 6 |
| 8 | 7 | 7 |
| 0 |
Reading from bottom to top (↑): 7 6 4
∴ (500)₁₀ = (764)₈
(c) Decimal to Hexadecimal: (2024)₁₀ = (?)₁₆
| Base | Number | Remainder |
|---|---|---|
| 16 | 2024 | 8 |
| 16 | 126 | 14 = E |
| 16 | 7 | 7 |
| 0 |
Reading from bottom to top (↑): 7 E 8
∴ (2024)₁₀ = (7E8)₁₆
2.2.3 Binary, Octal and Hexadecimal to Decimal
Expansion method: multiply each digit by its weight, then add.
(a) Binary to Decimal: (110101)₂ = (?)₁₀
| Binary digit | 1 | 1 | 0 | 1 | 0 | 1 |
| Weight (2ⁿ) | 2⁵ = 32 | 2⁴ = 16 | 2³ = 8 | 2² = 4 | 2¹ = 2 | 2⁰ = 1 |
| Digit × Weight | 32 | 16 | 0 | 4 | 0 | 1 |
Sum = 32 + 16 + 0 + 4 + 0 + 1 = 53
∴ (110101)₂ = (53)₁₀
(b) Octal to Decimal: (745)₈ = (?)₁₀
| Octal digit | 7 | 4 | 5 |
| Weight (8ⁿ) | 8² = 64 | 8¹ = 8 | 8⁰ = 1 |
| Digit × Weight | 448 | 32 | 5 |
Sum = 448 + 32 + 5 = 485
∴ (745)₈ = (485)₁₀
(c) Hexadecimal to Decimal: (3AF)₁₆ = (?)₁₀
| Hex digit | 3 | A (= 10) | F (= 15) |
| Weight (16ⁿ) | 16² = 256 | 16¹ = 16 | 16⁰ = 1 |
| Digit × Weight | 768 | 160 | 15 |
Sum = 768 + 160 + 15 = 943
∴ (3AF)₁₆ = (943)₁₀
2.2.4 Binary ↔ Octal (4 2 1 Method)
Each octal digit is made of 3 bits with place values 4, 2, 1.
(a) Binary to Octal: (101110011)₂ = (?)₈
Steps: group the bits in 3s from the right (add zeros on the left if needed) → add the place values (4 2 1) where the bit is 1.
| Group | Bits | Place values | Calculation | Octal digit |
|---|---|---|---|---|
| 1st | 1 0 1 | 4 2 1 | 4 + 0 + 1 | 5 |
| 2nd | 1 1 0 | 4 2 1 | 4 + 2 + 0 | 6 |
| 3rd | 0 1 1 | 4 2 1 | 0 + 2 + 1 | 3 |
∴ (101110011)₂ = (563)₈
(b) Octal to Binary: (624)₈ = (?)₂
Steps: write 4 2 1 above each octal digit and put 1 under the values that add up to the digit, 0 elsewhere.
| Octal digit | 4 | 2 | 1 | Binary group |
|---|---|---|---|---|
| 6 (= 4 + 2) | 1 | 1 | 0 | 110 |
| 2 (= 2) | 0 | 1 | 0 | 010 |
| 4 (= 4) | 1 | 0 | 0 | 100 |
∴ (624)₈ = (110010100)₂
2.2.5 Binary ↔ Hexadecimal (8 4 2 1 Method)
Each hexadecimal digit is made of 4 bits with place values 8, 4, 2, 1.
(a) Binary to Hexadecimal: (11010111)₂ = (?)₁₆
| Group | Bits | Place values | Calculation | Hex digit |
|---|---|---|---|---|
| 1st | 1 1 0 1 | 8 4 2 1 | 8 + 4 + 0 + 1 = 13 | D |
| 2nd | 0 1 1 1 | 8 4 2 1 | 0 + 4 + 2 + 1 = 7 | 7 |
∴ (11010111)₂ = (D7)₁₆
Another example (needs padding): (1011011110)₂
Group from the right: 10 1101 1110 → pad the first group → 0010 1101 1110
| Group | Bits | Calculation | Hex digit |
|---|---|---|---|
| 1st | 0 0 1 0 | 0 + 0 + 2 + 0 = 2 | 2 |
| 2nd | 1 1 0 1 | 8 + 4 + 0 + 1 = 13 | D |
| 3rd | 1 1 1 0 | 8 + 4 + 2 + 0 = 14 | E |
∴ (1011011110)₂ = (2DE)₁₆
(b) Hexadecimal to Binary: (9F2)₁₆ = (?)₂
| Hex digit | 8 | 4 | 2 | 1 | Binary group |
|---|---|---|---|---|---|
| 9 (= 8 + 1) | 1 | 0 | 0 | 1 | 1001 |
| F (= 15 = 8 + 4 + 2 + 1) | 1 | 1 | 1 | 1 | 1111 |
| 2 (= 2) | 0 | 0 | 1 | 0 | 0010 |
∴ (9F2)₁₆ = (100111110010)₂
2.2.6 Octal ↔ Hexadecimal (through Binary)
There is no direct method, so convert to binary first.
(a) Octal to Hexadecimal: (472)₈ = (?)₁₆
Step 1: Octal → Binary (4 2 1)
| Octal digit | 4 | 2 | 1 | Binary |
|---|---|---|---|---|
| 4 | 1 | 0 | 0 | 100 |
| 7 | 1 | 1 | 1 | 111 |
| 2 | 0 | 1 | 0 | 010 |
So (472)₈ = (100111010)₂
Step 2: Binary → Hexadecimal (8 4 2 1). Regroup in 4s from the right: 1 0011 1010 → 0001 0011 1010
| Group | 8 | 4 | 2 | 1 | Sum | Hex digit |
|---|---|---|---|---|---|---|
| 0001 | 0 | 0 | 0 | 1 | 1 | 1 |
| 0011 | 0 | 0 | 1 | 1 | 3 | 3 |
| 1010 | 1 | 0 | 1 | 0 | 10 | A |
∴ (472)₈ = (13A)₁₆
(b) Hexadecimal to Octal: (2C5)₁₆ = (?)₈
Step 1: Hex → Binary (8 4 2 1)
| Hex digit | 8 | 4 | 2 | 1 | Binary |
|---|---|---|---|---|---|
| 2 | 0 | 0 | 1 | 0 | 0010 |
| C (= 12) | 1 | 1 | 0 | 0 | 1100 |
| 5 | 0 | 1 | 0 | 1 | 0101 |
So (2C5)₁₆ = (001011000101)₂
Step 2: Binary → Octal (4 2 1). Regroup in 3s: 001 011 000 101
| Group | 4 | 2 | 1 | Sum | Octal digit |
|---|---|---|---|---|---|
| 001 | 0 | 0 | 1 | 1 | 1 |
| 011 | 0 | 1 | 1 | 3 | 3 |
| 000 | 0 | 0 | 0 | 0 | 0 |
| 101 | 1 | 0 | 1 | 5 | 5 |
∴ (2C5)₁₆ = (1305)₈
2.2.7 Conversion of Fractional Numbers
(a) Decimal fraction → Binary / Octal / Hexadecimal
Steps: multiply the fractional part by the base. Write the integer part of each result. Keep multiplying the new fractional part. Read the integer parts from top to bottom (↓).
(0.375)₁₀ = (?)₂
| Multiply | Result | Integer part |
|---|---|---|
| 0.375 × 2 | 0.75 | 0 |
| 0.75 × 2 | 1.50 | 1 |
| 0.50 × 2 | 1.00 | 1 |
Reading from top to bottom (↓): 0 1 1
∴ (0.375)₁₀ = (0.011)₂
Some fractions never end in binary (for example 0.1₁₀ = 0.000110011…₂). Stop after the required number of places and write "approximately".
(b) Decimal number with fraction: (26.75)₁₀ = (?)₁₆
Integer part (÷ 16)
| Base | Number | Remainder |
|---|---|---|
| 16 | 26 | 10 = A |
| 16 | 1 | 1 |
| 0 |
Reading from bottom to top (↑): 1A
Fractional part (× 16)
| Multiply | Result | Integer part |
|---|---|---|
| 0.75 × 16 | 12.00 | 12 = C |
∴ (26.75)₁₀ = (1A.C)₁₆
(c) Binary fraction → Decimal: (11.101)₂ = (?)₁₀
| Binary digit | 1 | 1 | . 1 | 0 | 1 |
| Weight | 2¹ = 2 | 2⁰ = 1 | 2⁻¹ = 0.5 | 2⁻² = 0.25 | 2⁻³ = 0.125 |
| Digit × Weight | 2 | 1 | 0.5 | 0 | 0.125 |
Sum = 2 + 1 + 0.5 + 0 + 0.125 = 3.625
∴ (11.101)₂ = (3.625)₁₀
(d) Binary fraction → Octal: (110.101)₂ = (?)₈
Group in 3s outward from the point: 110 . 101
| Group | 4 | 2 | 1 | Octal digit |
|---|---|---|---|---|
| 110 | 1 | 1 | 0 | 6 |
| 101 | 1 | 0 | 1 | 5 |
∴ (110.101)₂ = (6.5)₈
(e) Hexadecimal fraction → Binary: (2.A)₁₆ = (?)₂
| Hex digit | 8 | 4 | 2 | 1 | Binary |
|---|---|---|---|---|---|
| 2 | 0 | 0 | 1 | 0 | 0010 |
| A (= 10) | 1 | 0 | 1 | 0 | 1010 |
(2.A)₁₆ = (0010.1010)₂ → (10.101)₂ (after removing unnecessary zeros)
2.3 Binary Arithmetic
2.3.1 Binary Addition
| Operation | Result |
|---|---|
| 0 + 0 | 0 |
| 0 + 1 | 1 |
| 1 + 0 | 1 |
| 1 + 1 | 10 (write 0, carry 1) |
| 1 + 1 + 1 | 11 (write 1, carry 1) |
Example: 10111 + 1101 (23 + 13)
Carry → 1 1 1 1 1
1 0 1 1 1
+ 0 1 1 0 1
-------------
1 0 0 1 0 0
Step by step (right to left):
- 1 + 1 = 10 → write 0, carry 1
- 1 + 0 + carry 1 = 10 → write 0, carry 1
- 1 + 1 + carry 1 = 11 → write 1, carry 1
- 0 + 1 + carry 1 = 10 → write 0, carry 1
- 1 + 0 + carry 1 = 10 → write 0, carry 1
- Bring down the last carry 1
Answer = (100100)₂ (= 36 in decimal)
2.3.2 Binary Subtraction
| Operation | Result |
|---|---|
| 0 − 0 | 0 |
| 1 − 0 | 1 |
| 1 − 1 | 0 |
| 0 − 1 | 1 (borrow 1 from the next left bit) |
When you borrow, the 0 becomes 10 (two) and the left bit decreases by 1.
Example: 10110 − 1011 (22 − 11)
1 0 1 1 0
− 0 1 0 1 1
-------------
0 1 0 1 1
Step by step (right to left):
- 0 − 1 → borrow: 10 − 1 = 1 (the next bit 1 becomes 0)
- 0 (after borrowing) − 1 → borrow: 10 − 1 = 1 (the next bit 1 becomes 0)
- 0 (after borrowing) − 0 = 0
- 0 − 1 → borrow: 10 − 1 = 1 (the next bit 1 becomes 0)
- 0 − 0 = 0
Answer = (1011)₂ (= 11 in decimal)
2.3.3 Binary Multiplication
| Operation | Result |
|---|---|
| 0 × 0 | 0 |
| 0 × 1 | 0 |
| 1 × 0 | 0 |
| 1 × 1 | 1 |
Example: 1011 × 101 (11 × 5)
1011
× 101
--------
1011 ← 1011 × 1
0000 ← 1011 × 0 (shift one place left)
1011 ← 1011 × 1 (shift two places left)
--------
110111
Add the three rows using binary addition.
Answer = (110111)₂ (= 55 in decimal)
2.3.4 Binary Division
Binary division follows the same pattern as long division:
- Take enough bits from the left of the dividend to be greater than or equal to the divisor.
- Write 1 in the quotient and subtract the divisor. (If the part is smaller than the divisor, write 0 in the quotient and take one more bit.)
- Bring down the next bit.
- Repeat until all bits are used. What is left is the remainder.
Example 1: 1111 ÷ 11 (15 ÷ 3)
1 0 1
┌─────────
11 │ 1 1 1 1
-1 1
───
0 1 ← remainder 0, bring down 1: 01 is less than 11, so write 0 in the quotient
0 1 1 ← bring down 1: 011 = 11, so write 1 in the quotient
-1 1
───
0 ← remainder
| Step | Part of dividend | Compare with 11 | Quotient bit | Subtract | Remainder |
|---|---|---|---|---|---|
| 1 | 11 | 11 ≥ 11 | 1 | 11 − 11 | 0 |
| 2 | 01 (bring down 1) | 1 < 11 | 0 | – | 1 |
| 3 | 11 (bring down 1) | 11 ≥ 11 | 1 | 11 − 11 | 0 |
Quotient = 101, Remainder = 0
Example 2: 100111 ÷ 101 (39 ÷ 5)
1 1 1
┌─────────────
101 │ 1 0 0 1 1 1
-1 0 1 ← 100 < 101, so take one more bit: 1001 − 101
───────
1 0 0 1 ← remainder 100, bring down 1
-1 0 1
───────
1 0 0 1 ← remainder 100, bring down 1
-1 0 1
───────
1 0 0 ← remainder
| Step | Part of dividend | Compare with 101 | Quotient bit | Subtract | Remainder |
|---|---|---|---|---|---|
| 1 | 100 | 4 < 5 | 0 | – | 100 |
| 2 | 1001 (take next bit) | 9 ≥ 5 | 1 | 1001 − 101 | 100 |
| 3 | 1001 (bring down 1) | 9 ≥ 5 | 1 | 1001 − 101 | 100 |
| 4 | 1001 (bring down 1) | 9 ≥ 5 | 1 | 1001 − 101 | 100 |
Quotient = 111, Remainder = 100
2.3.5 Complement Method of Subtraction
A complement is a way of writing a negative value so that subtraction can be done by addition. This makes computer hardware simpler.
| Complement | How to find it |
|---|---|
| 1's complement | Change every 0 → 1 and every 1 → 0 |
| 2's complement | 1's complement + 1 |
Example: for 10110
| Bits | |
|---|---|
| Original number | 1 0 1 1 0 |
| 1's complement (flip every bit) | 0 1 0 0 1 |
| 2's complement (add 1) | 0 1 0 1 0 |
Subtraction using 1's complement (A − B)
- Make both numbers have the same number of bits (add zeros on the left).
- Find the 1's complement of B (the subtrahend).
- Add it to A (the minuend).
- If a carry comes out: remove the carry and add 1 to the result. The answer is positive.
- If there is no carry: the answer is negative. Find the 1's complement of the result and put a minus sign in front.
Subtraction using 2's complement (A − B)
- Make both numbers have the same number of bits.
- Find the 2's complement of B.
- Add it to A.
- If a carry comes out: simply discard the carry. The remaining bits are the answer (positive).
- If there is no carry: the answer is negative. Find the 2's complement of the result and put a minus sign in front.
Example 1: Subtract 10001 from 11011 (27 − 17)
(a) Using 1's complement
Both numbers have 5 bits: A = 11011, B = 10001
1's complement of B (10001) = 01110
1 1 0 1 1
+ 0 1 1 1 0
-----------
1 0 1 0 0 1 ← a carry (1) has come out
Remove the carry and add 1 to the remaining bits:
0 1 0 0 1
+ 1
-----------
0 1 0 1 0
Answer = (1010)₂ (= 10)
(b) Using 2's complement
2's complement of B: 01110 + 1 = 01111
1 1 0 1 1
+ 0 1 1 1 1
-----------
1 0 1 0 1 0 ← a carry (1) has come out
Discard the carry: 01010
Answer = (1010)₂ (= 10)
Example 2: Subtract 10110 from 01101 (13 − 22, negative answer)
(a) Using 1's complement
A = 01101, B = 10110
1's complement of B (10110) = 01001
0 1 1 0 1
+ 0 1 0 0 1
-----------
1 0 1 1 0 ← no carry, so the answer is negative
1's complement of the result: 10110 → 01001
Answer = −(1001)₂ (= −9)
(b) Using 2's complement
2's complement of B: 01001 + 1 = 01010
0 1 1 0 1
+ 0 1 0 1 0
-----------
1 0 1 1 1 ← no carry, so the answer is negative
2's complement of the result: 01000 + 1 = 01001
Answer = −(1001)₂ (= −9)
2.4 Boolean Algebra and Logic Gates
2.4.1 Boolean Algebra
Boolean algebra (named after George Boole) is the algebra of logic. It deals with binary variables, which can have only two values: TRUE (1) or FALSE (0). It is the mathematical base of digital circuits.
- Boolean variable: a variable that can be only 0 or 1, usually written with capital letters (A, B, X, Y).
- Boolean expression / logic function: an expression made from variables, operators, brackets and an equal sign. Example:
F = X·Y·Z′ + X·Y - Literal: each appearance of a variable or its complement in an expression.
Basic operators
| Operation | Symbol | Meaning |
|---|---|---|
| AND (logical multiplication) | . | Output is 1 only if all inputs are 1 |
| OR (logical addition) | + | Output is 1 if at least one input is 1 |
| NOT (complement) | ′ or a bar | Reverses the input |
Uses of Boolean algebra
- Designing and simplifying digital circuits
- Writing conditions in programs (if, while)
- Searching with AND / OR / NOT in databases and search engines
- Error checking, decision making and pattern recognition in software
2.4.2 Truth Table
A truth table lists all possible combinations of input values and the output for each combination. For n inputs, there are 2ⁿ rows (2 inputs → 4 rows, 3 inputs → 8 rows).
2.4.3 Logic Gates
A logic gate is an electronic circuit that performs a logical operation on one or more input signals and gives one output. Gates are the building blocks of digital circuits.
1. AND gate: Y = A · B
Output is 1 only when all inputs are 1. (Like two switches in series.)
| A | B | Y = A·B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
2. OR gate: Y = A + B
Output is 1 when at least one input is 1. (Like two switches in parallel.)
| A | B | Y = A+B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
3. NOT gate (inverter): Y = A′
Output is the opposite of the input. It has only one input.
| A | Y = A′ |
|---|---|
| 0 | 1 |
| 1 | 0 |
4. NAND gate: Y = (A · B)′
AND followed by NOT. Output is 0 only when all inputs are 1.
| A | B | A·B | Y = (A·B)′ |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
5. NOR gate: Y = (A + B)′
OR followed by NOT. Output is 1 only when all inputs are 0.
| A | B | A+B | Y = (A+B)′ |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 |
6. XOR (Exclusive-OR) gate: Y = A′·B + A·B′
Output is 1 when the inputs are different.
| A | B | A′ | B′ | A′·B | A·B′ | Y = A′B + AB′ |
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 | 0 |
7. XNOR (Exclusive-NOR) gate: Y = A·B + A′·B′
Output is 1 when the inputs are the same. It is the complement of XOR.
| A | B | A′ | B′ | A·B | A′·B′ | Y = AB + A′B′ |
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 1 | 0 | 1 |
Difference between NAND and NOR
| NAND gate | NOR gate |
|---|---|
| AND + NOT | OR + NOT |
| Y = (A·B)′ | Y = (A+B)′ |
| Output is 0 only when all inputs are 1 | Output is 1 only when all inputs are 0 |
| Output is 1 if at least one input is 0 | Output is 0 if at least one input is 1 |
Drawing the gate symbols
- AND: flat back, curved front (D-shape).
- OR: curved back, pointed front.
- NOT: a triangle with a small circle (bubble) at the output.
- NAND / NOR: the AND / OR shape with a bubble at the output.
- XOR: the OR shape with an extra curved line at the input side. XNOR has an extra bubble at the output.
Venn diagram view
Draw two overlapping circles A and B inside a rectangle (the universal set):
- A · B (AND): shade the overlapping part (intersection).
- A + B (OR): shade both circles completely (union).
- A′ (NOT): shade everything outside circle A.
Uses of logic gates
- All digital circuits (processor, memory, adders) are built using gates.
- XOR and XNOR gates are used in addition circuits and in error checking (parity) and comparison.
2.4.4 Laws of Boolean Algebra
Boolean laws are rules for manipulating Boolean expressions. They are used to simplify expressions and so reduce the number of gates in a circuit (circuit minimization).
| Law | AND form | OR form |
|---|---|---|
| Identity law | A · 1 = A | A + 0 = A |
| Null law | A · 0 = 0 | A + 1 = 1 |
| Idempotent law | A · A = A | A + A = A |
| Complement law | A · A′ = 0 | A + A′ = 1 |
| Involution (double negation) | (A′)′ = A | |
| Commutative law | A · B = B · A | A + B = B + A |
| Associative law | (A · B) · C = A · (B · C) | (A + B) + C = A + (B + C) |
| Distributive law | A · (B + C) = A·B + A·C | A + (B · C) = (A + B) · (A + C) |
| De Morgan's law | (A · B)′ = A′ + B′ | (A + B)′ = A′ · B′ |
Verification of the Associative Law: (A + B) + C = A + (B + C)
| A | B | C | A+B | B+C | (A+B)+C | A+(B+C) |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
The last two columns are the same, so (A + B) + C = A + (B + C). ✔
Verification of the Distributive Law: A · (B + C) = A·B + A·C
| A | B | C | B+C | A·(B+C) | A·B | A·C | A·B + A·C |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
The columns A·(B+C) and A·B + A·C are the same, so the law is verified. ✔
2.4.5 De Morgan's Theorems
Theorem 1: (A + B)′ = A′ · B′ The complement of a sum is equal to the product of the complements.
| A | B | A+B | (A+B)′ | A′ | B′ | A′·B′ |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
Theorem 2: (A · B)′ = A′ + B′ The complement of a product is equal to the sum of the complements.
| A | B | A·B | (A·B)′ | A′ | B′ | A′+B′ |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
In both tables the two last columns are equal, so both theorems are proved. ✔
2.4.6 Principle of Duality
The dual of a Boolean expression is found by:
- Changing every AND (·) to OR (+) and every OR (+) to AND (·)
- Changing every 0 to 1 and every 1 to 0
- Keeping the variables and their complements unchanged
Principle of duality: if a Boolean identity is true, then its dual is also true. That is why every law in the table above comes in an AND form and an OR form.
| Expression | Its dual |
|---|---|
| A · 0 = 0 | A + 1 = 1 |
| A · A′ = 0 | A + A′ = 1 |
| A · B′ | A + B′ |
| A′ · B + C | (A′ + B) · C |
2.4.7 Simplification of Boolean Expressions
Example 1: Simplify F = A·B + A·B′
F = A·B + A·B′
= A·(B + B′) [distributive law]
= A · 1 [complement law]
= A [identity law]
Example 2: Simplify F = A + A′·B
F = A + A′·B
= (A + A′)·(A + B) [distributive law]
= 1 · (A + B) [complement law]
= A + B [identity law]
Example 3: Simplify F = X·Y + X·Y′ + X′·Y
F = X·Y + X·Y′ + X′·Y
= X·(Y + Y′) + X′·Y [distributive law]
= X · 1 + X′·Y [complement law]
= X + X′·Y [identity law]
= (X + X′)·(X + Y) [distributive law]
= 1 · (X + Y) [complement law]
= X + Y
Example 4: Simplify F = A·B + A′·B·C + B·C
F = A·B + A′·B·C + B·C
= A·B + B·C·(A′ + 1) [taking B·C common]
= A·B + B·C · 1 [null law: A′ + 1 = 1]
= A·B + B·C [identity law]
= B·(A + C) [distributive law]
Example 5: Simplify F = P·Q′ + Q·(P + Q) + P·(P′ + Q)
F = P·Q′ + Q·(P + Q) + P·(P′ + Q)
= P·Q′ + P·Q + Q·Q + P·P′ + P·Q [distributive law]
= P·Q′ + P·Q + Q + 0 + P·Q [idempotent and complement laws]
= P·Q′ + P·Q + Q [P·Q + P·Q = P·Q]
= P·(Q′ + Q) + Q [distributive law]
= P · 1 + Q [complement law]
= P + Q
Example 6: Show that (A + B)·(A + C) = A + B·C
LHS = (A + B)·(A + C)
= A·A + A·C + B·A + B·C [distributive law]
= A + A·C + A·B + B·C [idempotent law]
= A·(1 + C + B) + B·C [taking A common]
= A · 1 + B·C [null law]
= A + B·C = RHS
Quick Revision
- Radix: number of different digits in a system → binary 2, octal 8, decimal 10, hexadecimal 16.
- Positional vs non-positional: value depends on position vs value fixed by the symbol.
- Decimal → other: divide by the base, read remainders bottom to top.
- Other → decimal: multiply each digit by its weight and add.
- Binary ↔ octal: groups of 3 bits (4 2 1). Binary ↔ hex: groups of 4 bits (8 4 2 1).
- Complement subtraction: carry comes out → positive answer; no carry → negative (take the complement again and put −).
- 2's complement = 1's complement + 1.
- NAND = 0 only when all inputs are 1. NOR = 1 only when all inputs are 0.
- XOR = 1 when inputs differ. XNOR = 1 when inputs are the same.
- De Morgan: (A + B)′ = A′·B′ and (A·B)′ = A′ + B′.
- Dual: swap AND ↔ OR and 0 ↔ 1; keep variables unchanged.
Practice Questions
Short Answer
- What is a number system? Differentiate between positional and non-positional number systems.
- Define radix. Write the radix of binary, octal, decimal and hexadecimal systems.
- What is the binary number system? Why is it used in computers?
- What is a truth table? Differentiate between NAND and NOR gates with truth tables.
- What is a logic gate? Draw the symbol and truth table of AND, OR and NOT gates.
- Prove De Morgan's theorems using truth tables.
- State and verify the associative and distributive laws of Boolean algebra.
- Write short notes on: (a) Principle of duality (b) Uses of Boolean algebra
Numerical Practice (with answers)
- Convert as indicated:
- (a) (AF9)₁₆ = (?)₂ → 101011111001
- (b) (100101)₂ = (?)₁₆ → 25
- (c) (129)₁₆ = (?)₈ → 451
- (d) (2EA)₁₆ = (?)₁₀ → 746
- Subtract 10001 from 11011 using 1's and 2's complement. → 1010
- Add 10111 and 1101. → 100100
- Multiply 1011 by 101. → 110111
- Divide 100111 by 101. → Quotient 111, Remainder 100
- Simplify: A·B + A·B′ + A′·B. → A + B
End of Unit 2 notes.