Computer Data Representation
Everything a computer stores — a letter, a number, an image, a sound, a video — must be converted into binary (0s and 1s) before the computer can work with it. Data representation is the set of techniques computers use to translate all types of information into binary and back again.
The Universal Language: Binary
A single binary digit is called a bit. A bit holds one of two values: 0 or 1. On its own, one bit carries very little information. Computers group bits together to represent larger values and more complex data.
1 bit = 0 or 1 (2 possible values) 2 bits = 00, 01, 10, 11 (4 possible values) 3 bits = 000 to 111 (8 possible values) 8 bits = 00000000 to 11111111 (256 possible values) = 1 Byte
With n bits, you can represent 2ⁿ unique values. This grows fast: 8 bits = 256 values, 16 bits = 65,536 values, 32 bits = over 4 billion values.
Representing Text: Character Encoding
Computers represent text by assigning a unique binary number to each character. The mapping between characters and their binary codes is called a character encoding standard.
ASCII (American Standard Code for Information Interchange)
ASCII assigns a 7-bit code (later extended to 8-bit) to 128 characters, covering English letters (A–Z, a–z), digits (0–9), punctuation, and control characters.
Character │ Decimal │ Binary ──────────┼─────────┼────────── A │ 65 │ 01000001 B │ 66 │ 01000010 a │ 97 │ 01100001 0 │ 48 │ 00110000 Space │ 32 │ 00100000
When you type the word "Hi" and save it, the computer stores: 01001000 01101001 (H = 72, i = 105 in ASCII).
Unicode and UTF-8
ASCII only covers English characters. Languages like Hindi, Chinese, Arabic, and Greek need different characters. Unicode is a universal standard that assigns a unique code point to over 149,000 characters from all human languages, plus emoji.
UTF-8 is the most common encoding for Unicode on the web. It uses 1 to 4 bytes per character — English letters still use 1 byte (staying compatible with ASCII), while other scripts use 2–4 bytes.
Representing Numbers
Integers (Whole Numbers)
Positive integers are stored directly in binary. Negative integers use a technique called two's complement, which allows the CPU to perform subtraction using the same addition circuits it already has.
Unsigned 8-bit integer range: 0 to 255 Signed 8-bit integer range: −128 to 127 Two's Complement of 5 (to get −5): Step 1: Write 5 in binary: 0000 0101 Step 2: Flip all bits: 1111 1010 Step 3: Add 1: 1111 1011 ← This is −5 in two's complement
Real Numbers (Floating Point)
Decimal numbers like 3.14 or 0.001 are stored using floating-point representation — similar to scientific notation but in binary.
Floating point structure (32-bit / Single Precision): ┌─────┬────────────┬──────────────────────────────────┐ │Sign │ Exponent │ Mantissa │ │1 bit│ 8 bits │ 23 bits │ └─────┴────────────┴──────────────────────────────────┘
The sign bit says positive or negative. The exponent sets the scale. The mantissa stores the significant digits. Together they represent a very wide range of real numbers, though with some rounding limitations.
Representing Images
A digital image is a grid of tiny coloured dots called pixels. Each pixel stores colour information as numbers.
Grayscale Images
In a grayscale image, each pixel uses 8 bits to store brightness from 0 (black) to 255 (white).
Pixel brightness: 0 = ████ Black 64 = ▓▓▓▓ Dark grey 128 = ▒▒▒▒ Medium grey 192 = ░░░░ Light grey 255 = White
Colour Images: The RGB Model
Colour pixels store three separate brightness values — one each for Red, Green, and Blue. Each channel uses 8 bits (0–255). Three channels = 24 bits per pixel = 16.7 million possible colours.
Colour │ Red │ Green │ Blue │ Hex Code ──────────────┼──────┼───────┼───────┼────────── Pure Red │ 255 │ 0 │ 0 │ #FF0000 Pure Green │ 0 │ 255 │ 0 │ #00FF00 Pure Blue │ 0 │ 0 │ 255 │ #0000FF Yellow │ 255 │ 255 │ 0 │ #FFFF00 White │ 255 │ 255 │ 255 │ #FFFFFF Black │ 0 │ 0 │ 0 │ #000000
A 10-megapixel photo stores 10,000,000 pixels × 24 bits = 240 million bits = 30 megabytes of raw data before compression.
Representing Audio
Sound is a continuous wave. Computers digitise audio through a process called sampling — measuring the sound wave's amplitude (loudness) at regular intervals and storing each measurement as a binary number.
Audio Wave (analog):
/\/\/\
/ \ /\
───/ \ / \──── Time →
\/
Sampled (digital): each dot is a stored binary value
· ·
· · · · ·
· · ·
──·──────────────────── Time →
CD audio samples 44,100 times per second (44.1 kHz) with 16-bit precision per sample. That gives high-quality audio with 65,536 possible amplitude levels at each sample point.
Representing Video
Video is a sequence of still images (frames) played rapidly — typically 24, 30, or 60 frames per second — combined with synchronised audio. One second of uncompressed Full HD video contains:
1 frame at 1920×1080 = 2,073,600 pixels × 24 bits = ~6 MB 30 frames per second × 6 MB = ~180 MB per second of raw video
Video compression codecs like H.264, H.265, and AV1 reduce this dramatically by storing only the changes between frames rather than every frame in full. This is why a 2-hour movie fits on a 4 GB file instead of requiring terabytes of storage.
Summary of Data Representation Methods
Data Type │ Representation Method ────────────┼────────────────────────────────────── Text │ ASCII / Unicode (character encoding) Integers │ Direct binary / Two's complement Decimals │ Floating point (IEEE 754 standard) Colour │ RGB channels (24-bit colour) Images │ Grid of pixels with colour values Audio │ Sampled amplitude values (PCM) Video │ Sequence of compressed image frames
Every file on your computer — no matter how complex — is ultimately a long string of 0s and 1s that the relevant software knows how to interpret using these encoding standards.
