How Computers Understand Data
Discover the basics of the binary number system and the machine instruction cycle.
Knowledge of Computers › Fundamentals of computer sciences · 20 min read
In the previous chapter, "Secondary Storage and Memory Units," we explored exactly where your data lives—from the massive capacity of your hard drive to the lightning-fast temporary workspace of your RAM. But knowing where data is stored leaves a massive question unanswered: how does the computer actually read it?
When you open a photograph, type a document, or play a video game, you see colors, letters, and 3D graphics. But the Central Processing Unit (CPU)—the brain of the computer—is completely blind to all of that. It does not know what the letter "A" is. It does not know what the color red looks like. It does not understand English, Hindi, or even high-level programming languages like Python or Java.
The CPU only understands one thing: Machine Language, a seemingly endless stream of electrical pulses that we represent as 0s and 1s.
In this chapter, we are going to strip away the illusion of the computer screen. We will learn exactly how human information (like numbers, text, and images) is translated into the binary language of 0s and 1s. Then, we will look inside the CPU itself to understand the "Machine Cycle"—the exact, step-by-step heartbeat that allows a processor to fetch those 1s and 0s, figure out what they mean, and execute them billions of times per second.
The Physical Reality: Why 0s and 1s?
Before we do any math, we need to understand why computers use 0s and 1s. It is not because early computer scientists just happened to like the numbers zero and one. It is a physical necessity born out of how electronic hardware works.
At its microscopic core, a computer's processor is made up of billions of tiny electronic switches called transistors. Think of a transistor exactly like the light switch on your bedroom wall. A light switch only has two possible states:
- 1OFF (No electricity is flowing)
- 2ON (Electricity is flowing)
Because the hardware only has two states, the language we use to communicate with that hardware can only have two "letters." We use the digit 0 to represent the OFF state (low voltage), and the digit 1 to represent the ON state (high voltage).
Every single piece of data in a computer—every text message you send, every pixel in a YouTube video, every password you type—must eventually be broken down into a sequence of these ON and OFF switches. A single 0 or 1 is called a bit (short for binary digit). Group eight of these bits together, and you get a byte.
The Binary Number System: Counting Like a Computer
To understand how computers handle numbers, we first need to look at how we handle numbers.
Humans use the Decimal Number System (also called Base-10). We have ten unique digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Why ten? Because we have ten fingers. When we count up and run out of digits (after 9), we don't invent a new symbol. Instead, we add a new "column" to the left (the tens column), put a 1 there, and reset the ones column to 0. That gives us 10.
Computers use the Binary Number System (Base-2). They only have two "fingers": 0 and 1. When a computer counts, it runs out of digits almost immediately.
- Zero is `0`.
- One is `1`.
- Now we are out of digits! To make "two," the computer has to add a new column to the left and reset the first column to zero. So, two is `10` (read as "one-zero", not "ten").
- Three is `11`.
- Out of digits again! To make "four," we add another column. Four is `100`.
The Magic of Positional Weights
In our human Base-10 system, every column is worth ten times the column to its right. You know these as the Ones, Tens, Hundreds, and Thousands columns.
- The number 345 means: (3 × 100) + (4 × 10) + (5 × 1).
In the computer's Base-2 system, every column is worth two times the column to its right. The columns are the Ones, Twos, Fours, Eights, Sixteens, Thirty-Twos, and so on.
- The binary number 1101 means: (1 × 8) + (1 × 4) + (0 × 2) + (1 × 1).
- Add those up: 8 + 4 + 0 + 1 = 13 in our human decimal system.
Worked Example: Converting Between Decimal and Binary
In competitive exams, you are frequently asked to translate a number from human language (Decimal) to computer language (Binary), or vice versa. Let's walk through the foolproof methods for both.
Method 1: Decimal to Binary (The "Divide by 2" Method)
Let’s convert the decimal number 25 into binary. The rule is simple: Divide the number by 2. Write down the quotient (the whole number answer) and the remainder. Keep dividing the new quotient by 2 until you hit 0. Your binary answer is the remainders read from bottom to top.
- 125 ÷ 2 = 12, Remainder 1
- 212 ÷ 2 = 6, Remainder 0
- 36 ÷ 2 = 3, Remainder 0
- 43 ÷ 2 = 1, Remainder 1
- 51 ÷ 2 = 0, Remainder 1
Now, read the remainders from the bottom step up to the top step: 11001. Therefore, 25 in decimal is 11001 in binary.
Method 2: Binary to Decimal (The "Positional Weights" Method)
Let’s convert the binary number 10110 into decimal. Write the binary number out with plenty of space. Below it, write the binary column weights starting from 1 on the far right and doubling as you move left.
Binary digits: 1 0 1 1 0 Column weights: 16 8 4 2 1
Now, simply add together the column weights that have a 1 above them. Ignore the columns that have a 0.
- We have a 1 in the 16 column.
- We have a 0 in the 8 column (ignore).
- We have a 1 in the 4 column.
- We have a 1 in the 2 column.
- We have a 0 in the 1 column (ignore).
Math: 16 + 4 + 2 = 22. Therefore, 10110 in binary is 22 in decimal.
Representing Data Digitally: Beyond Just Numbers
We now know how computers handle numbers. But you don't just use your computer as a calculator. You type essays, look at photos, and listen to music. How does a system that only understands numbers process a photograph of a sunset or a text message?
The answer is encoding. We create standardized rulebooks that assign a specific number to every non-numerical piece of data. Since the computer can handle numbers (via binary), it can handle anything, as long as we translate it into numbers first.
1. Representing Text (ASCII and Unicode)
To represent text, computer scientists created a dictionary where every letter, punctuation mark, and symbol is assigned a unique number.
The most famous early rulebook is ASCII (American Standard Code for Information Interchange). In ASCII, the capital letter A is assigned the decimal number 65. When you press 'A' on your keyboard, the keyboard sends the number 65 to the CPU. The CPU instantly converts 65 into binary (01000001) and processes it.
- 'B' is 66 (01000010).
- 'C' is 67 (01000011).
- Even a blank space has a number (32).
2. Representing Images (Pixels)
If you zoom in close enough to your smartphone screen, you will see that the image is made up of thousands of tiny, microscopic squares of color. These are called pixels (Picture Elements).
To a computer, an image is just a massive grid of pixels, and each pixel is represented by numbers. Most screens use the RGB (Red, Green, Blue) color model. Every pixel is assigned three numbers, representing how much Red, Green, and Blue light should be mixed together.
- Pure Red is (255, 0, 0).
- Pure Green is (0, 255, 0).
- Pure White is (255, 255, 255).
- Pure Black is (0, 0, 0).
When you save a photo, the computer just saves a massive list of binary numbers representing the RGB values of every single pixel from the top-left corner to the bottom-right corner.
3. Representing Sound (Sampling)
Sound is a continuous physical wave traveling through the air. To get this into a computer, a microphone measures the height (amplitude) of the sound wave thousands of times per second. This process is called sampling. Each measurement is recorded as a number. A standard MP3 file is just a long list of binary numbers representing the exact shape of the sound wave, measured 44,100 times every single second!
The Anatomy of a Machine Instruction
Now that we know how data is turned into binary, we need to look at how the CPU actually does things with that data.
When you write a program in a language like Python, a piece of software called a compiler or interpreter translates your human-readable code into Machine Language—the raw binary instructions the CPU can execute.
To the CPU, a single machine instruction is just a string of 0s and 1s. But the CPU knows how to split this string into two distinct parts: the Opcode and the Operand.
Imagine a chef in a kitchen. If the instruction is "Chop the Onion":
- "Chop" is the Opcode (the action).
- "The Onion" is the Operand (the data being acted upon).
In a simplified 16-bit computer system, an instruction might look like this: `0010 000000001101`
- The first 4 bits (`0010`) might be the Opcode for "ADD".
- The remaining 12 bits (`000000001101`) might be the Operand, pointing to memory address 13, where a specific number is stored.
The Machine Cycle: The Heartbeat of the CPU
We have finally arrived at the core of how a computer works. You have a program loaded into your RAM, consisting of millions of binary instructions (Opcodes and Operands). How does the CPU actually process them?
It uses a relentless, four-step loop called the Machine Cycle (sometimes called the Instruction Cycle or the Fetch-Execute cycle). From the moment you turn your computer on to the moment you shut it down, the CPU is doing nothing but repeating these four steps, billions of times per second.
The four steps are: Fetch, Decode, Execute, and Store.
The Machine Cycle
- 11. FETCH: The CPU retrieves the next instruction from RAM.
- 22. DECODE: The Control Unit translates the instruction to understand what needs to be done.
- 33. EXECUTE: The ALU or other components actually perform the requested action.
- 44. STORE: The result of the execution is written back to a register or memory.
Let's break down exactly what happens in each step. To understand this, you need to know that the CPU has a few tiny, ultra-fast storage areas inside it called Registers.
- The Program Counter (PC) is a register that keeps track of where the next instruction is located in RAM.
- The Instruction Register (IR) is a register that holds the current instruction being worked on.
Step 1: Fetch (Getting the Instruction)
The CPU looks at the Program Counter (PC) to find the memory address of the next instruction. The CPU's Control Unit sends a signal across the motherboard to the RAM, asking for the data at that specific address. The RAM sends the binary instruction back to the CPU, where it is placed safely into the Instruction Register (IR). Finally, the Program Counter automatically increments by one, so it is ready to point to the next instruction for the next cycle.
Step 2: Decode (Understanding the Instruction)
Now the instruction is sitting inside the CPU, but it's just a raw string of 0s and 1s. The Control Unit (CU) takes over. The CU is the traffic cop of the CPU. It reads the Opcode (the first few bits) to figure out what operation is required. Does this instruction mean ADD? Does it mean MOVE data? Does it mean JUMP to a different part of the program? The Control Unit decodes the binary and prepares the necessary internal circuits for the next step.
Step 3: Execute (Doing the Work)
The actual work happens here. The Control Unit sends signals to the relevant parts of the CPU to carry out the instruction.
- If the instruction was a math problem (like ADD or MULTIPLY) or a logical comparison (like "Is A greater than B?"), the task is handed over to the Arithmetic Logic Unit (ALU).
- If the instruction was simply to move data from one place to another, the Control Unit handles the transfer.
Step 4: Store (Saving the Result)
Once the ALU has calculated the result, that result cannot just vanish into thin air. It must be saved. In the Store phase, the CPU writes the result of the execution phase into an internal CPU register or sends it back out across the motherboard to be saved in the RAM.
Once Step 4 is complete, the cycle instantly loops back to Step 1, fetching the next instruction.
Clock Speed: How Fast is the Cycle?
When you buy a computer or a smartphone, you will see the processor speed advertised in Gigahertz (GHz)—for example, a "3.2 GHz Intel Core i7". What does that number actually mean in the context of what we just learned?
Inside the CPU, there is a microscopic quartz crystal called the System Clock. It generates a steady, rhythmic electrical pulse. Think of it like a metronome for a musician, or the drummer on a rowing boat. Every time the clock "ticks," the CPU moves forward by one step in the Machine Cycle.
- 1 Hertz (Hz) means one cycle per second.
- 1 Megahertz (MHz) means one million cycles per second.
- 1 Gigahertz (GHz) means one billion cycles per second.
Therefore, if you have a 3.2 GHz processor, its internal clock is ticking 3.2 billion times every single second. That means the CPU is capable of performing the Fetch-Decode-Execute-Store cycle billions of times in the blink of an eye. This unimaginable speed is what allows a computer to take simple binary instructions and use them to render complex 3D video games in real-time.
Quick Revision
- Binary System: Computers use Base-2 (0s and 1s) because their physical hardware relies on transistors that only have two states: ON (1) and OFF (0).
- Decimal to Binary: Divide the decimal number by 2 repeatedly. The binary answer is the remainders read from bottom to top.
- Binary to Decimal: Write the positional weights (1, 2, 4, 8, 16...) under the binary number from right to left. Add up the weights that have a '1' above them.
- Data Encoding: Text is converted to binary using standards like ASCII and Unicode. Images are broken into pixels and assigned RGB number values. Sound is sampled into numerical wave heights.
- Instruction Anatomy: A machine instruction consists of an Opcode (what action to perform) and an Operand (what data to perform it on).
- The Machine Cycle: The four-step process the CPU uses to process instructions: Fetch (get from RAM), Decode (understand it), Execute (do the math/logic), and Store (save the result).
- Key CPU Components: The Control Unit (CU) decodes instructions and directs traffic. The Arithmetic Logic Unit (ALU) executes mathematical and logical operations.
- Registers: The Program Counter (PC) holds the address of the next instruction. The Instruction Register (IR) holds the current instruction being processed.
- Clock Speed: Measured in Hertz (Hz). A 3 GHz processor executes 3 billion machine cycles per second.
Related notes
- How a Computer Actually Works
Understand the basic block diagram of a computer, including the CPU, ALU, and Control Unit.
- The Five Generations of Computers
Trace the evolution of computers from early vacuum tubes to modern artificial intelligence.
- Types of Computers Explained
Learn the difference between microcomputers, mainframes, supercomputers, and hybrid systems.
- Computer Memory: RAM, ROM, and Cache
Understand how primary memory works and the difference between volatile and non-volatile storage.