On This Page

It All Starts With Electricity

At its heart, a computer is a machine that manipulates electricity. A wire either has current flowing through it, or it doesn’t. That’s it. Two states. We call them ON and OFF — or in mathematics, 1 and 0.

Physical state → Digital representation
OFF
0
ON
1

A single 0 or 1 is called a bit (short for binary digit) — the smallest unit of data in computing. Eight bits grouped together make one byte, which can represent 256 different values (0–255).

By combining billions of these tiny on/off switches — called transistors — computers can represent and process any kind of information imaginable. Before we see how, we need to understand the number system this makes possible.

The Binary Number System

You already know decimal — base 10. It uses ten digits (0–9) and the value of each digit depends on its position. Each position is a power of 10. Binary works identically, but uses only two digits (0 and 1) and each position is a power of 2.

Decimal (Base 10) BASE 10
10⁷
10⁶
10⁵
10⁴
10³
10²
10¹
10⁰
10000000
1000000
100000
10000
1000
100
10
1
0
0
0
0
2
4
7
3
2×1000 + 4×100 + 7×10 + 3×1 = 2473
Binary (Base 2) BASE 2
2⁷
2⁶
2⁵
2⁴
2⁰
128
64
32
16
8
4
2
1
0
1
0
1
1
0
1
1
64+16+8+2+1 = 91
Interactive: Click bits to toggle ON/OFF 8-BIT CONVERTER
Decimal value
0
 
Binary
00000000
Hex
0x00

Encoding Everything as Numbers

Once we can represent numbers in binary, we can represent anything — as long as we agree on a mapping. Text, images, sounds, and videos are all stored as numbers inside a computer.

ASCII maps each character to a number. The letter ‘A’ is 65 in decimal, or 01000001 in binary. Every keystroke you type is stored as a number.

Modern text uses Unicode (UTF-8), which extends ASCII to support over 140,000 characters including emojis — but the principle is identical: every character has a unique number, which is stored in binary.

Images are broken into a grid of tiny squares called pixels. Each pixel stores a colour value as a number. In the simplest case (1-bit images), each pixel is either 0 (white) or 1 (black) — like the example below. With more bits per pixel, we get more colours: an 8-bit greyscale image uses values 0–255, and a full colour image stores three values per pixel — Red, Green, Blue (0–255 each), using 24 bits per pixel.

8×8 pixel image
Each cell = 1 bit (1=black, 0=white)

Sound is a wave — continuous vibrations in air. To store it digitally, we sample the wave thousands of times per second, recording its amplitude (height) as a number each time. CD audio samples 44,100 times per second at 16 bits — enough to fool the human ear completely.

Amplitude samples → numbers

Higher sample rate (samples/second) and higher bit depth (bits per sample) give better audio quality — but also larger file sizes. This is the trade-off at the heart of data compression.

Transistors & Logic Gates

A transistor is a tiny electronic switch, etched into silicon. It has an input signal that controls whether electricity flows through it or not. When the input is ON (1), current flows — the switch is closed. When the input is OFF (0), no current flows — the switch is open.

TRANSISTOR INPUT 1 = ON OUTPUT current flows →

The Transistor: The Building Block of All Computing

Modern CPUs contain billions of transistors, each smaller than a virus. By connecting transistors in specific arrangements, we build logic gates — circuits that perform logical operations on binary inputs (0s and 1s). These are the building blocks of all computation.

AND
Output is 1 only if both inputs are 1. Like requiring two keys to open a lock.
ABA AND B
000
010
100
111
OR
Output is 1 if at least one input is 1. Like a door with two different locks — either key works.
ABA OR B
000
011
101
111
NOT
Inverts the input. Also called an inverter — turns 0 to 1 and 1 to 0.
ANOT A
01
10
XOR
Output is 1 if inputs are different. The foundation of binary addition.
ABA XOR B
000
011
101
110

By combining just these simple gates, we can build adders (to add numbers), multiplexers (to route data), and ultimately the entire Arithmetic Logic Unit (ALU) — the part of the CPU that does all calculations.

The CPU & Fetch–Decode–Execute

The Central Processing Unit is the chip that runs your programs. It continuously performs one cycle: fetch an instruction from memory, decode what it means, and execute it. This happens billions of times per second.

Storage
Registers
Ultra-fast temporary storage inside the CPU. Holds the current instruction, memory addresses, and calculation values.
PC — Program Counter
CIR — Current Instruction Reg
ACC — Accumulator
MAR — Memory Address Reg
MDR — Memory Data Reg
Central Processing Unit
CPU
▸ Control Unit (CU)
▸ Arithmetic Logic Unit (ALU)
▸ Cache Memory
▸ Clock (GHz)
Connected via Bus
Memory
RAM holds the currently running program and data. The CPU fetches instructions from RAM addresses one by one.
The Fetch–Decode–Execute Cycle
STEP 01 FETCH
STEP 02 DECODE
STEP 03 EXECUTE
LOOP REPEAT ↺
The Program Counter (PC) holds the memory address of the next instruction. The CPU copies this address into the MAR and retrieves the instruction from RAM into the MDR, then into the CIR.

Memory & Storage

Not all storage is equal. The CPU needs data instantly, but large storage is slow. Computers use a hierarchy — faster and more expensive near the CPU, slower and cheaper further away. Storage is either volatile (data is lost when the power is turned off, like RAM) or non-volatile (data is kept permanently, like an SSD or hard drive).

Registers
Inside CPU ~0.3 ns · Bytes Fastest possible. Holds data being actively used right now.
Cache (L1/L2/L3)
On CPU chip ~1–10 ns · KB–MB Stores recently used instructions & data to speed up access.
RAM
Main memory — volatile ~60–100 ns · GB Holds the OS, running programs and open files. Fast but temporary — data is lost when the computer is switched off.
Secondary Storage
HDD / SSD / USB — non-volatile ~0.1–10 ms · TB Permanently stores files, OS, applications. Loaded into RAM when needed. Data survives power off.

When you open an application: the OS loads it from secondary storage → RAM. The CPU fetches instructions from RAM → Cache → Registers. When you save a file, data travels in the reverse direction back to secondary storage.

What about ROM? ROM (Read-Only Memory) is a separate type of non-volatile memory that stores the BIOS/UEFI firmware — the small program that runs when you first switch on your computer, before the operating system loads. Unlike RAM, ROM keeps its data when the power is off, and unlike secondary storage, it is not used for saving your files.

The Full Journey

Every operation a computer performs follows the same chain, from physics to logic:

01

Electricity

Physical current flows or doesn’t flow through silicon — two states: ON (1) and OFF (0).

02

Binary Numbers

Sequences of 1s and 0s form numbers using place value — each position is a power of 2, just as decimal uses powers of 10.

03

Encoding Data

We map numbers to letters (ASCII/Unicode), colours (RGB), and audio samples — everything becomes a number, and numbers become bits.

04

Transistors & Logic Gates

Billions of transistors act as switches. Arranged into AND, OR, NOT, XOR gates, they perform boolean operations — the atoms of all calculation.

05

CPU: Fetch–Decode–Execute

The CPU reads instructions from memory, interprets them using the Control Unit, and the ALU executes them — billions of times per second.

06

Memory Hierarchy

Programs live in secondary storage, are loaded into RAM, cached near the CPU, and processed in registers. Data flows up and down this chain constantly.