The math optional, made finite. Daily Practice

Algebra of Binary Numbers

At a Glance

Why This Chapter Matters

Binary arithmetic is mechanical once the rules are memorised, but UPSC rewards clear column-by-column working and explicit carry notation. The 2023 paper set two sub-parts — one on addition/subtraction and one on 2’s complement — so both archetypes are tested. These are quick marks if prepared, but errors cascade without careful carry tracking.

Minimum Theory

Binary digit (bit) values. A number written in base 2 uses only digits 0 and 1. The positional value of bit kk (counting from the right, starting at 0) is 2k2^k.

Binary addition rules.

0+0=0,0+1=1,1+0=1,1+1=102 (sum 0, carry 1),1+1+1=112 (sum 1, carry 1)0+0=0,\quad 0+1=1,\quad 1+0=1,\quad 1+1=10_2 \text{ (sum 0, carry 1)},\quad 1+1+1=11_2 \text{ (sum 1, carry 1)}

Work right to left; propagate the carry into the next column.

Binary subtraction. Compute ABA - B by either:

1’s complement. Flip every bit: 1011=0100\overline{1011} = 0100.

2’s complement. N-N in 2’s complement =N+1= \overline{N} + 1 (1’s complement plus 1). Equivalently, leave all trailing zeros and the rightmost 1 unchanged; flip all bits to the left of that rightmost 1.

Range of nn-bit 2’s complement. 2n1-2^{n-1} to 2n112^{n-1}-1.

Binary multiplication. Shift-and-add: for each bit of the multiplier, if the bit is 1 write a shifted copy of the multiplicand; if 0 write zeros. Sum all partial products.

Binary division. Long division in base 2: at each step, check whether the divisor fits into the current partial dividend (quotient bit 1 if yes, 0 if no); subtract and bring down the next bit.

XOR (exclusive OR). AB=1A \oplus B = 1 iff ABA \ne B. Used in half-adder carry-free sum: the sum bit of A+BA+B is ABA \oplus B, the carry bit is ABA \cdot B.

Question Archetypes

ArchetypeRecognition
binary-additionAdd two binary numbers; show carry row
twos-complement-subtractionSubtract using 2’s complement; interpret result
binary-multiplicationMultiply two binary numbers using shift-and-add

binary-addition (sub-part; 2023)

Recognition Cues

Solution Template

  1. Align numbers on the right, padding shorter number with leading zeros.
  2. Add column by column from right to left, tracking carry.
  3. Write the carry row explicitly above the sum row.
  4. State the result and, if asked, convert to decimal to verify.

Worked Example

2023 Paper 2, 2023-P2-Q7a (5 marks)

Perform binary addition: 101101012+01101110210110101_2 + 01101110_2.

Arrange the numbers and add column by column (carries shown above):

  Carry:  1 1 1 1 1 1 0 0
          1 0 1 1 0 1 0 1
        + 0 1 1 0 1 1 1 0
          -----------------
        1 0 0 1 0 0 0 1 1

Detailed column trace (right to left):

Result: 1001000112100100011_2.

Verification. 101101012=1811010110101_2 = 181_{10}, 011011102=1101001101110_2 = 110_{10}, sum =29110=1001000112= 291_{10} = 100100011_2 ✓.

101101012+011011102=1001000112\boxed{10110101_2 + 01101110_2 = 100100011_2}


twos-complement-subtraction (sub-part; 2023)

Recognition Cues

Solution Template

  1. Write both numbers in nn-bit binary (choose nn large enough to hold both and a sign bit).
  2. Find 2’s complement of the subtrahend: flip all bits, add 1.
  3. Add the minuend to the 2’s complement of the subtrahend.
  4. If there is a carry out of the most significant bit, discard it — the result is positive.
  5. If there is no carry out and the MSB of the result is 1, the result is negative; take its 2’s complement to find the magnitude.

Worked Example

2023 Paper 2, 2023-P2-Q7b (5 marks)

Using 8-bit 2’s complement arithmetic, subtract 451045_{10} from 731073_{10}, i.e., compute 734573 - 45.

Step 1 — convert to 8-bit binary.

7310=010010012,4510=00101101273_{10} = 01001001_2, \quad 45_{10} = 00101101_2

Step 2 — 2’s complement of 451045_{10}.

1’s complement of 0010110100101101: flip every bit 11010010\to 11010010.

Add 1: 11010010+1=1101001111010010 + 1 = 11010011.

So 45-45 in 8-bit 2’s complement is 11010011211010011_2.

Step 3 — add 7373 and (45)(-45).

  Carry:  0 1 0 0 1 0 0 1
          0 1 0 0 1 0 0 1   (73)
        + 1 1 0 1 0 0 1 1   (2's complement of 45)
          -----------------
        1 0 0 0 1 1 1 0 0

Result bits (8 bits): 00011100200011100_2; carry out of bit 7 = 1, discarded.

Step 4 — interpret.

Carry out exists \Rightarrow result is positive. 000111002=281000011100_2 = 28_{10}.

Verification. 7345=2873 - 45 = 28 ✓.

73104510=000111002=2810\boxed{73_{10} - 45_{10} = 00011100_2 = 28_{10}}

Common Traps

Marks-Aware Writing

Each 5-mark sub-part expects: the setup (numbers aligned, conversion if needed), explicit column-by-column working for addition, and a decimal verification. For 2’s complement: show the 1’s complement step and the add-1 step separately — they are two distinct operations and each earns marks. Combining them without showing intermediate work loses the method marks.

Practice Set

Only one historical paper set these sub-parts (2023), both shown above.

We've mapped all 13 years of this exam. Get new chapters, tools, and solutions as we release them — free.