📘 Detailed Notes: Number System and Binary
Operations
Table of Contents
1. Number Systems Overview
2. Conversion Between Number Systems
3. Decimal ↔ Binary
4. Decimal ↔ Octal
5. Decimal ↔ Hexadecimal
6. Fractions in Binary
7. Binary Arithmetic
8. Addition
9. Subtraction
10. Multiplication
11. Division
12. Bitwise Operations
13. AND, OR, XOR, NOT
14. Shifts
15. Signed Number Representations
16. Signed Magnitude
17. One’s Complement
18. Two’s Complement
19. Special Number Representations
20. Gray Code
21. Binary Coded Decimal (BCD)
22. Most Important Points (Theory Summary)
1. Number Systems Overview
• Decimal (Base 10): Digits 0–9. Example: 345 → (3×100 + 4×10 + 5).
• Binary (Base 2): Digits 0,1. Example: 1011₂ = 11₁₀.
• Octal (Base 8): Digits 0–7. Example: 345₈ = 229₁₀.
• Hexadecimal (Base 16): Digits 0–9, A–F. Example: 2F₁₆ = 47₁₀.
2. Conversion Between Number Systems
Decimal → Binary
Method: Divide by 2 repeatedly, collect remainders (bottom to top). - 13₁₀ → 1101₂ - 45₁₀ → 101101₂ - 100₁₀
→ 1100100₂ - 255₁₀ → 11111111₂ - 1024₁₀ → 10000000000₂
1
Binary → Decimal
Method: Multiply each digit by 2^position. - 1101₂ = 13₁₀ - 101101₂ = 45₁₀ - 1100100₂ = 100₁₀ - 11111111₂ =
255₁₀ - 10000000000₂ = 1024₁₀
Decimal Fractions → Binary
Method: Multiply fraction by 2, take integer part, repeat. - 0.625₁₀ = 0.101₂ - 0.1₁₀ ≈ 0.000110011…₂ - 0.2₁₀ ≈
0.001100110…₂ - 0.375₁₀ = 0.011₂ - 2.75₁₀ = 10.11₂
Decimal → Octal & Hexadecimal
• 254₁₀ = 376₈ = FE₁₆
• 4095₁₀ = 7777₈ = FFF₁₆
• 1234₁₀ = 2322₈ = 4D2₁₆
• 65535₁₀ = 177777₈ = FFFF₁₆
• 305441741₁₀ = 2215125715₈ = 1234ABCD₁₆
3. Binary Arithmetic
Addition
Rules: 0+0=0, 0+1=1, 1+1=10 (carry 1). - 1011 + 1101 = 11000 - 111 + 1 = 1000 - 1001 + 0110 = 1111 - 101010
+ 110101 = 1011111 - 1111 + 0001 = 10000
Subtraction
Borrowing when needed. - 1101 – 1010 = 11 - 1000 – 1 = 111 - 10100 – 01111 = 101 - 10000 – 10001 = -1 -
10011 – 01001 = 1010
Multiplication
Like decimal long multiplication. - 101 × 11 = 1111 - 110 × 101 = 11110 - 1111 × 10 = 11110 - 1010 × 1010 =
1100100 - 1001 × 100 = 100100
Division
Repeated subtraction or long division. - 1100 ÷ 11 = 100 (remainder 0) - 1111 ÷ 11 = 101 (remainder 0) -
10000 ÷ 10 = 1000 (remainder 0) - 10110 ÷ 10 = 1011 (remainder 0) - 11001 ÷ 101 = 101 (remainder 0)
4. Bitwise Operations
Given x=10110110, y=11001100: - x & y = 10000100 - x | y = 11111110 - x ^ y = 01111010 - ~x (8-bit) =
01001001
2
Shifts: - n=1101011 (107₁₀) - n << 1 = 11010110 (214₁₀) - n >> 1 = 110101 (53₁₀)
5. Signed Number Representations (4-bit)
Decimal Signed Magnitude 1’s Complement 2’s Complement
-3 -0011 1100 1101
-2 -0010 1101 1110
-1 -0001 1110 1111
0 0000 0000 0000
1 0001 0001 0001
2 0010 0010 0010
3 0011 0011 0011
6. Special Number Representations
Gray Code
Formula: G = B ⊕ (B >> 1) - 0000 → 0000 - 0001 → 0001 - 0011 → 0010 - 0101 → 0111 - 1111 → 1000
Binary Coded Decimal (BCD)
Each decimal digit → 4-bit binary. - 0 → 0000 - 1 → 0001 - 2 → 0010 - 3 → 0011 - 4 → 0100 - 5 → 0101 - 6 →
0110 - 7 → 0111 - 8 → 1000 - 9 → 1001
7. Most Important Points (Theory Summary)
• Binary is the foundation of all digital systems.
• Decimal-to-binary conversion is based on repeated division; fractional parts use repeated
multiplication.
• Octal and hexadecimal are used for compact binary representation (grouping 3 and 4 bits
respectively).
• Binary arithmetic follows simple rules, but overflow must always be checked.
• Bitwise operators are crucial in low-level programming and optimization.
• Two’s complement is the most widely used signed number system for handling negative integers.
• Gray code is useful in error correction and digital communication to avoid multiple-bit errors.
• BCD is used in calculators and digital clocks for decimal display.
3
✅ These notes now include important theory points along with examples for quick last-minute revision.