Part 1: Fundamental Concepts of Computing
2. How Computers Represent Data
How Computers Represent Data
A computer has no concept of letters, colours, or music. Underneath everything it stores and moves numbers, and those numbers are written in a two-symbol system called binary. Understanding this layer removes a lot of the mystery from programming.
Bits and Bytes
The smallest unit of information is a bit — a single switch that is either 0 (off) or 1 (on). A single bit is not very useful, so bits are grouped. Eight bits together form one byte. One byte can represent 256 different values (from 0 to 255), which is enough to store a single character of English text.
Analogy: a bit is like one light switch, which only tells you "on or off". A byte is a row of eight switches — by choosing a pattern across all eight, you can signal 256 distinct messages.
Why Binary?
Computers use binary because electronic circuits are naturally good at two clear states: high voltage or low voltage, current flowing or not. Two states are reliable and cheap to build, so the whole machine is designed around counting in twos instead of the tens we humans use.
Binary Place Values
In our familiar decimal system each column is worth ten times the one to its right (1, 10, 100…). In binary each column is worth two times the one to its right. Here are the place values of one byte:
| Bit position | 8th | 7th | 6th | 5th | 4th | 3rd | 2nd | 1st |
|---|---|---|---|---|---|---|---|---|
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| Example bits | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 |
To read the example, add the place values wherever a bit is 1: 64 + 8 + 4 + 1 = 77. So the binary number 01001101 equals 77 in decimal.
Converting Decimal to Binary
To turn a decimal number into binary, repeatedly ask "does the largest remaining place value fit?" For 77: 128 is too big (0), 64 fits (1, leaving 13), 32 no (0), 16 no (0), 8 fits (1, leaving 5), 4 fits (1, leaving 1), 2 no (0), 1 fits (1). That reproduces 01001101.
Hexadecimal: A Shorthand
Long strings of 0s and 1s are hard for humans to read, so programmers often use hexadecimal (base 16). Hex uses sixteen symbols: 0–9 then A–F (where A=10 … F=15). One hex digit neatly represents exactly four bits, so two hex digits describe one byte.
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 5 | 0101 | 5 |
| 10 | 1010 | A |
| 15 | 1111 | F |
| 77 | 0100 1101 | 4D |
| 255 | 1111 1111 | FF |
Text, Images, and Sound Are Numbers Too
- Text: Each character is assigned a number. The old ASCII standard maps
Ato 65,ato 97, and so on. Modern Unicode extends this to cover every language's characters plus emoji. - Images: A picture is a grid of tiny dots called pixels. Each pixel stores numbers for its red, green, and blue brightness — typically one byte each, giving millions of possible colours.
- Sound: A microphone measures air pressure thousands of times per second; each measurement is saved as a number. Playing them back in order recreates the sound.
The big takeaway: everything inside a computer — this sentence, your photos, your music — is ultimately just numbers written in binary. When you program, you are arranging and transforming those numbers in meaningful ways.