Binary, Number Systems & Digital Codes

Complete, exam-ready learning module explaining why binary is used, how other number systems relate to it, and how conversions work internally.

1. Why Computers Use Binary

Digital computers are built using transistors that have two stable states. Binary maps naturally to these states.

  • 0 → OFF (Low voltage)
  • 1 → ON (High voltage)
  • Noise resistant
  • Hardware efficient

2. Number Systems in Digital Computers

Decimal

Base-10, human friendly

Binary

Base-2, machine language

Octal

Base-8, 3-bit grouping

Hexadecimal

Base-16, 4-bit grouping

3. Relationship with Binary

Binary BitsEquivalent
31 Octal digit
41 Hex digit
81 Byte

4. Positional Weight & Fractional Binary

Each position has a weight based on the base. Binary also supports fractions.

Example: (101.101)2

= 1×2² + 0×2¹ + 1×2⁰ + 1×2⁻¹ + 0×2⁻² + 1×2⁻³ = 4 + 1 + 0.5 + 0.125 = 5.625

5. Decimal → Binary (Step-by-Step)

6. Binary → Decimal (Weight Method)

7. Binary → Octal → Hex (Grouping)

8. Digital Codes

BCD

Decimal digits separately encoded

Gray Code

Single-bit transition, error reduction

ASCII

Text representation standard

9. Signed vs Unsigned Numbers

Binary numbers can be interpreted in two ways:

  • Unsigned: All bits represent magnitude
  • Signed: MSB represents sign (2’s complement)
TypeRange (8-bit)
Unsigned0 to 255
Signed-128 to +127

Exam Tip: MSB = 1 → negative number (signed)

Signed / Unsigned Visualizer (8-bit)

10. Binary Addition (With Carry Animation)

11. Signed Overflow Detection

Overflow occurs when:

  • Two positive numbers give negative result
  • Two negative numbers give positive result

Overflow is ignored in unsigned arithmetic.

12. Binary Subtraction (2’s Complement)

13. Gray ↔ Binary Conversion

14. Binary Multiplication (Shift & Add)

Binary multiplication follows the shift-and-add principle. Each bit of the multiplier decides whether a shifted multiplicand is added.

  • Left shift by 1 → multiply by 2
  • Bit = 1 → add shifted value
  • Bit = 0 → skip

Hardware Insight: Implemented using shift registers and adders in the ALU.

15. Binary Division (Long Division)

Binary division is similar to decimal long division. It uses repeated comparison, subtraction, and shifting.

  • Compare shifted divisor
  • Subtract when possible
  • Shift right step-by-step

Hardware Insight: Uses restoring or non-restoring division algorithms.

16. Binary Arithmetic – Exam Summary

  • Binary addition uses carry propagation
  • Subtraction uses 2’s complement
  • Multiplication = shift + add
  • Division = subtract + shift
  • Overflow applies only to signed numbers
Digital Computer Architecture • Binary & Codes • Learning Module