Number System and Conversion Boolean Logic

    Number System and Conversion Boolean Logic

    Reading Mode:

    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.

    SystemBaseDigits usedExample
    Decimal100 – 9(789)₁₀
    Binary20, 1(1101)₂
    Octal80 – 7(572)₈
    Hexadecimal160 – 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, …

    BaseWeights (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)

    DecimalBinaryOctalHexadecimal
    0000000
    1000111
    2001022
    3001133
    4010044
    5010155
    6011066
    7011177
    81000108
    91001119
    10101012A
    11101113B
    12110014C
    13110115D
    14111016E
    15111117F

    2.2 Number Conversion

    2.2.1 Summary of Methods

    ConversionMethod
    Decimal → Binary / Octal / HexadecimalDivide repeatedly by 2 / 8 / 16; read the remainders from bottom to top
    Binary / Octal / Hexadecimal → DecimalMultiply each digit by its weight and add (expansion method)
    Binary ↔ Octal4 2 1 method (groups of 3 bits)
    Binary ↔ Hexadecimal8 4 2 1 method (groups of 4 bits)
    Octal ↔ HexadecimalConvert through binary

    2.2.2 Decimal to Binary, Octal and Hexadecimal

    Steps

    1. Divide the number by the base and write the remainder beside it.
    2. Divide the quotient again by the base. Repeat until the quotient becomes 0.
    3. Read the remainders from bottom to top.

    (a) Decimal to Binary: (45)₁₀ = (?)₂

    BaseNumberRemainder
    2451
    2220
    2111
    251
    220
    211
    0

    Reading the remainders from bottom to top (↑): 1 0 1 1 0 1

    ∴ (45)₁₀ = (101101)₂

    (b) Decimal to Octal: (500)₁₀ = (?)₈

    BaseNumberRemainder
    85004
    8626
    877
    0

    Reading from bottom to top (↑): 7 6 4

    ∴ (500)₁₀ = (764)₈

    (c) Decimal to Hexadecimal: (2024)₁₀ = (?)₁₆

    BaseNumberRemainder
    1620248
    1612614 = E
    1677
    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 digit110101
    Weight (2ⁿ)2⁵ = 322⁴ = 162³ = 82² = 42¹ = 22⁰ = 1
    Digit × Weight32160401

    Sum = 32 + 16 + 0 + 4 + 0 + 1 = 53

    ∴ (110101)₂ = (53)₁₀

    (b) Octal to Decimal: (745)₈ = (?)₁₀

    Octal digit745
    Weight (8ⁿ)8² = 648¹ = 88⁰ = 1
    Digit × Weight448325

    Sum = 448 + 32 + 5 = 485

    ∴ (745)₈ = (485)₁₀

    (c) Hexadecimal to Decimal: (3AF)₁₆ = (?)₁₀

    Hex digit3A (= 10)F (= 15)
    Weight (16ⁿ)16² = 25616¹ = 1616⁰ = 1
    Digit × Weight76816015

    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.

    GroupBitsPlace valuesCalculationOctal digit
    1st1 0 14 2 14 + 0 + 15
    2nd1 1 04 2 14 + 2 + 06
    3rd0 1 14 2 10 + 2 + 13

    ∴ (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 digit421Binary group
    6 (= 4 + 2)110110
    2 (= 2)010010
    4 (= 4)100100

    ∴ (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)₂ = (?)₁₆

    GroupBitsPlace valuesCalculationHex digit
    1st1 1 0 18 4 2 18 + 4 + 0 + 1 = 13D
    2nd0 1 1 18 4 2 10 + 4 + 2 + 1 = 77

    ∴ (11010111)₂ = (D7)₁₆

    Another example (needs padding): (1011011110)₂ Group from the right: 10 1101 1110 → pad the first group → 0010 1101 1110

    GroupBitsCalculationHex digit
    1st0 0 1 00 + 0 + 2 + 0 = 22
    2nd1 1 0 18 + 4 + 0 + 1 = 13D
    3rd1 1 1 08 + 4 + 2 + 0 = 14E

    ∴ (1011011110)₂ = (2DE)₁₆

    (b) Hexadecimal to Binary: (9F2)₁₆ = (?)₂

    Hex digit8421Binary group
    9 (= 8 + 1)10011001
    F (= 15 = 8 + 4 + 2 + 1)11111111
    2 (= 2)00100010

    ∴ (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 digit421Binary
    4100100
    7111111
    2010010

    So (472)₈ = (100111010)₂

    Step 2: Binary → Hexadecimal (8 4 2 1). Regroup in 4s from the right: 1 0011 1010 → 0001 0011 1010

    Group8421SumHex digit
    0001000111
    0011001133
    1010101010A

    ∴ (472)₈ = (13A)₁₆

    (b) Hexadecimal to Octal: (2C5)₁₆ = (?)₈

    Step 1: Hex → Binary (8 4 2 1)

    Hex digit8421Binary
    200100010
    C (= 12)11001100
    501010101

    So (2C5)₁₆ = (001011000101)₂

    Step 2: Binary → Octal (4 2 1). Regroup in 3s: 001 011 000 101

    Group421SumOctal digit
    00100111
    01101133
    00000000
    10110155

    ∴ (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)₁₀ = (?)₂

    MultiplyResultInteger part
    0.375 × 20.750
    0.75 × 21.501
    0.50 × 21.001

    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)

    BaseNumberRemainder
    162610 = A
    1611
    0

    Reading from bottom to top (↑): 1A

    Fractional part (× 16)

    MultiplyResultInteger part
    0.75 × 1612.0012 = C

    ∴ (26.75)₁₀ = (1A.C)₁₆

    (c) Binary fraction → Decimal: (11.101)₂ = (?)₁₀

    Binary digit11. 101
    Weight2¹ = 22⁰ = 12⁻¹ = 0.52⁻² = 0.252⁻³ = 0.125
    Digit × Weight210.500.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

    Group421Octal digit
    1101106
    1011015

    ∴ (110.101)₂ = (6.5)₈

    (e) Hexadecimal fraction → Binary: (2.A)₁₆ = (?)₂

    Hex digit8421Binary
    200100010
    A (= 10)10101010

    (2.A)₁₆ = (0010.1010)₂ → (10.101)₂ (after removing unnecessary zeros)


    2.3 Binary Arithmetic

    2.3.1 Binary Addition

    OperationResult
    0 + 00
    0 + 11
    1 + 01
    1 + 110 (write 0, carry 1)
    1 + 1 + 111 (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 + 1 = 10 → write 0, carry 1
    2. 1 + 0 + carry 1 = 10 → write 0, carry 1
    3. 1 + 1 + carry 1 = 11 → write 1, carry 1
    4. 0 + 1 + carry 1 = 10 → write 0, carry 1
    5. 1 + 0 + carry 1 = 10 → write 0, carry 1
    6. Bring down the last carry 1

    Answer = (100100)₂ (= 36 in decimal)

    2.3.2 Binary Subtraction

    OperationResult
    0 − 00
    1 − 01
    1 − 10
    0 − 11 (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):

    1. 0 − 1 → borrow: 10 − 1 = 1 (the next bit 1 becomes 0)
    2. 0 (after borrowing) − 1 → borrow: 10 − 1 = 1 (the next bit 1 becomes 0)
    3. 0 (after borrowing) − 0 = 0
    4. 0 − 1 → borrow: 10 − 1 = 1 (the next bit 1 becomes 0)
    5. 0 − 0 = 0

    Answer = (1011)₂ (= 11 in decimal)

    2.3.3 Binary Multiplication

    OperationResult
    0 × 00
    0 × 10
    1 × 00
    1 × 11

    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:

    1. Take enough bits from the left of the dividend to be greater than or equal to the divisor.
    2. 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.)
    3. Bring down the next bit.
    4. 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
    
    StepPart of dividendCompare with 11Quotient bitSubtractRemainder
    11111 ≥ 11111 − 110
    201 (bring down 1)1 < 110–1
    311 (bring down 1)11 ≥ 11111 − 110

    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
    
    StepPart of dividendCompare with 101Quotient bitSubtractRemainder
    11004 < 50–100
    21001 (take next bit)9 ≥ 511001 − 101100
    31001 (bring down 1)9 ≥ 511001 − 101100
    41001 (bring down 1)9 ≥ 511001 − 101100

    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.

    ComplementHow to find it
    1's complementChange every 0 → 1 and every 1 → 0
    2's complement1's complement + 1

    Example: for 10110

    Bits
    Original number1 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)

    1. Make both numbers have the same number of bits (add zeros on the left).
    2. Find the 1's complement of B (the subtrahend).
    3. Add it to A (the minuend).
    4. If a carry comes out: remove the carry and add 1 to the result. The answer is positive.
    5. 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)

    1. Make both numbers have the same number of bits.
    2. Find the 2's complement of B.
    3. Add it to A.
    4. If a carry comes out: simply discard the carry. The remaining bits are the answer (positive).
    5. 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

    OperationSymbolMeaning
    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 barReverses 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.)

    ABY = A·B
    000
    010
    100
    111

    2. OR gate: Y = A + B

    Output is 1 when at least one input is 1. (Like two switches in parallel.)

    ABY = A+B
    000
    011
    101
    111

    3. NOT gate (inverter): Y = A′

    Output is the opposite of the input. It has only one input.

    AY = A′
    01
    10

    4. NAND gate: Y = (A · B)′

    AND followed by NOT. Output is 0 only when all inputs are 1.

    ABA·BY = (A·B)′
    0001
    0101
    1001
    1110

    5. NOR gate: Y = (A + B)′

    OR followed by NOT. Output is 1 only when all inputs are 0.

    ABA+BY = (A+B)′
    0001
    0110
    1010
    1110

    6. XOR (Exclusive-OR) gate: Y = A′·B + A·B′

    Output is 1 when the inputs are different.

    ABA′B′A′·BA·B′Y = A′B + AB′
    0011000
    0110101
    1001011
    1100000

    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.

    ABA′B′A·BA′·B′Y = AB + A′B′
    0011011
    0110000
    1001000
    1100101

    Difference between NAND and NOR

    NAND gateNOR gate
    AND + NOTOR + NOT
    Y = (A·B)′Y = (A+B)′
    Output is 0 only when all inputs are 1Output is 1 only when all inputs are 0
    Output is 1 if at least one input is 0Output 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).

    LawAND formOR form
    Identity lawA · 1 = AA + 0 = A
    Null lawA · 0 = 0A + 1 = 1
    Idempotent lawA · A = AA + A = A
    Complement lawA · A′ = 0A + A′ = 1
    Involution (double negation)(A′)′ = A
    Commutative lawA · B = B · AA + B = B + A
    Associative law(A · B) · C = A · (B · C)(A + B) + C = A + (B + C)
    Distributive lawA · (B + C) = A·B + A·CA + (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)

    ABCA+BB+C(A+B)+CA+(B+C)
    0000000
    0010111
    0101111
    0111111
    1001011
    1011111
    1101111
    1111111

    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

    ABCB+CA·(B+C)A·BA·CA·B + A·C
    00000000
    00110000
    01010000
    01110000
    10000000
    10111011
    11011101
    11111111

    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.

    ABA+B(A+B)′A′B′A′·B′
    0001111
    0110100
    1010010
    1110000

    Theorem 2: (A · B)′ = A′ + B′ The complement of a product is equal to the sum of the complements.

    ABA·B(A·B)′A′B′A′+B′
    0001111
    0101101
    1001011
    1110000

    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:

    1. Changing every AND (·) to OR (+) and every OR (+) to AND (·)
    2. Changing every 0 to 1 and every 1 to 0
    3. 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.

    ExpressionIts dual
    A · 0 = 0A + 1 = 1
    A · A′ = 0A + 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

    1. What is a number system? Differentiate between positional and non-positional number systems.
    2. Define radix. Write the radix of binary, octal, decimal and hexadecimal systems.
    3. What is the binary number system? Why is it used in computers?
    4. What is a truth table? Differentiate between NAND and NOR gates with truth tables.
    5. What is a logic gate? Draw the symbol and truth table of AND, OR and NOT gates.
    6. Prove De Morgan's theorems using truth tables.
    7. State and verify the associative and distributive laws of Boolean algebra.
    8. Write short notes on: (a) Principle of duality (b) Uses of Boolean algebra

    Numerical Practice (with answers)

    1. Convert as indicated:
      • (a) (AF9)₁₆ = (?)₂ → 101011111001
      • (b) (100101)₂ = (?)₁₆ → 25
      • (c) (129)₁₆ = (?)₈ → 451
      • (d) (2EA)₁₆ = (?)₁₀ → 746
    2. Subtract 10001 from 11011 using 1's and 2's complement. → 1010
    3. Add 10111 and 1101. → 100100
    4. Multiply 1011 by 101. → 110111
    5. Divide 100111 by 101. → Quotient 111, Remainder 100
    6. Simplify: A·B + A·B′ + A′·B. → A + B

    End of Unit 2 notes.