Recall warm-up
- Write 0xB6 in binary.
Stuck? Peek at 0.2.2 Binary, decimal and hex; powers of 2
- Binary places: 1, 2, 4, 8, 16, 32, 64, 128, …; MSB left, LSB right.
- Hex: one digit = 4 bits; A–F = 10–15; group from the right.
- k bits → 2ᵏ values, 0 … 2ᵏ − 1.
- Bits needed for N values = smallest k with 2ᵏ ≥ N.
- 2¹⁰ = 1024 · 2¹⁶ = 65,536 · 2²⁰ ≈ 1.05 M · 2³² ≈ 4.29 × 10⁹.
- Bits in 3 KB?
Stuck? Peek at 0.2.1 Bits, bytes and prefixes: powers of 10 for rates, powers of 2 for sizes
- 1 B = 8 b. Lower-case b = bit, upper-case B = byte.
- Rates: k = 10³, M = 10⁶, G = 10⁹ (bps).
- Sizes: K = 2¹⁰, M = 2²⁰, G = 2³⁰ (bytes) — unless the question says 1000.
- Time to push out = (size in bits) ÷ (rate in bit/s).
- ms = 10⁻³ s, µs = 10⁻⁶ s, ns = 10⁻⁹ s.
- What carries bits on a link?
Stuck? Peek at 0.1.1 Why networks exist: hosts, links and sending data
- Network = devices + links that exchange data.
- Host = where a message starts or ends (laptop, phone, server).
- Link = physical path: copper (voltage), fibre (light), wireless (radio).
- All content → bits → signals → bits → content; meaning comes from an agreed encoding.
- One link per pair of n hosts: n(n − 1)/2 links — too many, so links are shared.
The Hook
Signals on a link get disturbed: a spark, a scratch on a fibre, a microwave oven near Wi-Fi. A 0 can arrive as a 1. The receiver needs a cheap way to notice. The tricks it uses are made of three bit operations you learn today: XOR, 1's complement addition and modulo-2 division. Phase 2 turns each one into an error-catching method.
Predict First
XOR outputs 1 when its two input bits are different. What is 1011 XOR 1011? And what happens if you XOR a pattern with the same key twice?
,1011 XOR 1011 = 0000 — anything XOR itself is zero. XOR twice with the same key gives back the original: (A ⊕ K) ⊕ K = A. That "undo" property is why XOR shows up everywhere.
Core Concept
AND, OR, NOT, XOR
Bitwise operators work on each position independently:
| a | b | a AND b | a OR b | a XOR b (a ⊕ b) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
XOR properties
- a ⊕ 0 = a; a ⊕ a = 0; order does not matter.
- (a ⊕ k) ⊕ k = a — XOR undoes itself.
- XOR is addition without carry: 1 + 1 = 0, nothing carried.
- The number of 1s in a ⊕ b counts the positions where a and b differ.
1's complement
1's-complement addition adds two k-bit numbers normally, and if a carry falls off the left end, that carry is wrapped around and added back at the right end ("end-around carry").
The supplied notes include an interactive visual for this concept; this reading view preserves the surrounding explanation and sequence.
Modulo-2 arithmetic
In modulo-2 arithmetic there are no carries and no borrows: addition and subtraction are both XOR. A bit string can be read as a polynomial: 1011 = x³ + x + 1 (the 1s mark which powers of x are present).
| Bits | Polynomial |
|---|---|
| 1011 | x³ + x + 1 |
| 10011 | x⁴ + x + 1 |
| 101 | x² + 1 |
Modulo-2 long division
Long division where each "subtract" is an XOR. At each step look at the leading bit of the current chunk: if it is 1, XOR with the divisor (quotient bit 1); if 0, XOR with zeros (quotient bit 0). Bring down the next bit and repeat. The remainder has one bit fewer than the divisor.
11101 ← quotient
101 ) 1101011
101 ← leading 1: XOR with divisor
---
111
101 ← leading 1: XOR with divisor
---
100
101 ← leading 1: XOR with divisor
---
011
000 ← leading 0: XOR with zeros
---
111
101 ← leading 1: XOR with divisor
---
10 ← remainder (2 bits)Putting it together
- XOR marks differences and undoes itself; it is addition without carries.
- 1's-complement addition wraps the carry around; the complement flips every bit.
- Modulo-2 division uses XOR at each step; the remainder is one bit shorter than the divisor.
Visual
1100001110 ← quotient
10011 ) 11010111110000
10011 ← leading 1: XOR with divisor
-----
10011
10011 ← leading 1: XOR with divisor
-----
00001
00000 ← leading 0: XOR with zeros
-----
00011
00000 ← leading 0: XOR with zeros
-----
00111
00000 ← leading 0: XOR with zeros
-----
01111
00000 ← leading 0: XOR with zeros
-----
11110
10011 ← leading 1: XOR with divisor
-----
11010
10011 ← leading 1: XOR with divisor
-----
10010
10011 ← leading 1: XOR with divisor
-----
00010
00000 ← leading 0: XOR with zeros
-----
0010 ← remainder (4 bits)Worked Examples
Compute 11001010 AND 11110000, OR, and XOR.
Show the full solution
AND = 11000000 (keeps the left nibble — AND with 1111 0000 is a mask). OR = 11111010. XOR = 00111010.
16-bit 1's-complement sum of 0x9F3A and 0x7B21, then the 1's complement of the sum.
Show the full solution
0x9F3A + 0x7B21 = 0x11A5B (17 bits). Wrap the carry: 0x1A5B + 1 = 0x1A5C.
Complement: 0xFFFF − 0x1A5C = 0xE5A3 (flip every bit).
Divide 11010111110000 by 10011 using modulo-2 division. What is the remainder?
Show the full solution
Divisor has 5 bits, so the remainder has 4. Work left to right, XOR-ing whenever the leading bit is 1 (full working in the Visual section). Remainder = 0010.
GATE Traps
- In modulo-2 division, decide by the leading bit, not by "is the chunk bigger than the divisor".
- The remainder always has exactly (divisor length − 1) bits — keep leading zeros (0010, not 10).
- 1's-complement addition wraps the carry back in; ordinary binary addition just drops it.
Memory Hook
XOR = "spot the difference". Wrap-around = the carry walks round the back and rejoins at the start.
Connect the Dots
XOR (spotting differences), 1's-complement sums and modulo-2 remainders are exactly the three error-catching tools of Phase 2. Next (0.2.4): shared links are a game of chance — what is the probability that exactly one of many senders speaks? For that we need logarithms and basic probability.
Self-Test
- MCQ
1101 ⊕ 0110 = ?
- 1011
- 0100
- 1111
- 0011
- NAT
8-bit 1's-complement sum of 11111111 and 00000001, as a decimal number?
Write your answer before opening the key.
- MCQ
Remainder of 1101011 ÷ 101 in modulo-2 division:
- 10
- 01
- 11
- 00
- MSQ
Which are true in modulo-2 arithmetic?
- Addition and subtraction are the same operation.
- 1 + 1 = 0 with no carry.
- The bit string 10011 is the polynomial x⁴ + x + 1.
- The remainder of division by a 5-bit divisor has 5 bits.
- MCQ
The 16-bit 1's complement of 0x1A5C is:
- 0xE5A3
- 0xE5A4
- 0x1A5B
- 0xA5C1
Rule Card
- AND (mask), OR, NOT (flip), XOR (1 where bits differ).
- a ⊕ a = 0, a ⊕ 0 = a, (a ⊕ k) ⊕ k = a.
- 1's complement = flip all bits; 1's-complement addition wraps the end carry back in.
- Modulo-2: + = − = XOR, no carries; bits ↔ polynomial.
- Mod-2 division: leading 1 → XOR divisor; leading 0 → XOR zeros; remainder = (divisor length − 1) bits.
Concept Ledger
- bitwise AND / OR / NOT
- XOR (⊕)
- 1's complement
- 1's-complement addition (end-around carry)
- modulo-2 arithmetic
- polynomial view of a bit string
- modulo-2 division, remainder
Answer Vault
Try the questions first. Open when you are ready to check.
Warm-up answers
- 1011 0110.
- 3 × 1024 × 8 = 24,576.
- Signals — voltage, light or radio.
Self-test answers
- A — Bit by bit: 1⊕0=1, 1⊕1=0, 0⊕1=1, 1⊕0=1 → 1011.
- B: That is 1101 AND 0110.
- C: That is 1101 OR 0110.
- D: Differs from the correct 1011 in the leftmost bit (1 ⊕ 0 = 1, not 0).
- 1 — 255 + 1 = 256 = 1 00000000 → wrap the carry: 00000001 = 1.
- A — Long division with XOR gives quotient 11101 and remainder 10.
- B: Bits reversed.
- C: An arithmetic slip in the last XOR.
- D: 00 would mean the divisor divides exactly; it does not.
- ABC — Both are XOR; no carries; 10011 → x⁴ + x + 1.
- D: The remainder has one bit fewer than the divisor: 4 bits.
- A — 0xFFFF − 0x1A5C = 0xE5A3 (flip every bit).
- B: That is the 2's complement (flip and add 1), not the 1's complement.
- C: That is the value minus 1.
- D: Digits rotated — not a complement.
Flashcards
- a ⊕ a = ?
Reveal answer
0. And (a ⊕ k) ⊕ k = a. - How does 1's-complement addition treat the final carry?
Reveal answer
It wraps it around and adds it at the right end. - Remainder length for a 5-bit divisor?
Reveal answer
4 bits. - 10011 as a polynomial?
Reveal answer
x⁴ + x + 1.
Exam shortcuts
- 1's-complement sum, fast: add in decimal or hex as usual; if the result ≥ 2ᵏ, subtract 2ᵏ and add 1. — k-bit words; repeat if the wrap itself overflows (rare).
- Complement of a hex word: subtract from 0xFFFF (each digit from F). — 16-bit words; for k bits subtract from 2ᵏ − 1.