12 min read Beginner Lesson 04 (of 30)
Course 01 · Part 1 — Foundations

Lesson 04 — Bits, Bytes and How Data is Represented in Computers

To a computer, text, images, songs, videos, and software code are all ultimately data—and that data is built from magical combinations of bits.

Brief Introduction

Your computer might store thousands of photos, hundreds of music tracks, and countless high-definition movies. Your documents, installed apps, games, and operating system all live on your storage drive.

Yet to the computer hardware, none of these are inherently "pictures," "songs," "videos," or "sentences."

Physical computer hardware operates exclusively on bits.

  • How do billions of bits assemble into a realistic photo?
  • How does the word Hello get preserved in storage?
  • How does a 2 GB movie fit onto flash chips?

In this lesson, we break down data representation step by step.

1. Bit — The Smallest Digital Building Block

As seen in the previous lesson, a computer's digital system operates on two distinct physical states: 0 or 1.

A single binary digit is named a Bit (Binary Digit).

Bit value: 0 | Bit value: 1

A lone bit can represent very little information by itself. To represent complex reality, computers group many bits together.

2. What Happens When We Combine Multiple Bits?

With 2 bits, we unlock 4 distinct combinations:

00
01
10
11

Total: 2² = 4 combinations

3 bits: 2³ = 8 | 4 bits: 2⁴ = 16 combinations

Fundamental Rule

n bits → 2ⁿ possible combinations

The more bits grouped together, the richer the information that can be encoded.

3. What Is a Byte?

In computer architecture, the most vital standard group of bits is the Byte.

1 Byte = 8 bits 2⁸ = 256 distinct combinations

Example: 10110101 (8 binary digits = 1 byte).

Range: from 00000000 to 11111111.

4. Units Beyond the Byte

As data scales, we use standard decimal and binary prefix multiples:

Byte KB (Kilobyte) MB (Megabyte) GB (Gigabyte) TB (Terabyte) PB (Petabyte)

5. Is a KB Always 1024 Bytes?

In traditional binary systems: 1 KB = 1024 Bytes (2¹⁰).

However, modern drive manufacturers measure storage using decimal powers of 10: 1 kB = 1,000 Bytes (10³).

Binary Units (IEC standard):

1 KiB = 1,024 Bytes
1 MiB = 1,024 KiB
1 GiB = 1,024 MiB

Decimal Units (SI standard):

1 kB = 1,000 Bytes
1 MB = 1,000,000 Bytes
1 GB = 1,000,000,000 Bytes

This explains why a drive labeled "500 GB" on its packaging appears as ~465 GB inside Windows.

6. Storing Numbers in Binary

Consider storing the positive decimal integer 13:

13 = (1 × 8) + (1 × 4) + (0 × 2) + (1 × 1) → 1101₂

Hardware arithmetic circuits manipulate these binary place-value bits directly to perform addition and calculation.

7. How Negative Numbers Are Stored

If positive 5 is stored as binary, how does a computer store -5?

Modern computers universally represent signed negative integers using Two's Complement.

With two's complement, subtraction is performed using the exact same hardware addition circuits without needing dedicated subtraction logic.

8. Floating-Point Numbers (Decimals)

How do computers encode real numbers like 3.14159?

Hardware uses the IEEE 754 Floating-Point Standard, which divides bits into a Sign bit, an Exponent, and a Mantissa (fractional part).

0.1 + 0.2 ≠ exactly 0.3 (produces 0.30000000000000004 in JavaScript/Python)

This is not a software bug; it is an inherent artifact of representing base-10 fractions in finite binary bits.

9. How Text Becomes Binary

To store a word like Hello, we need an agreed convention that maps every character to a specific numeric identifier: Character Encoding.

ASCII Encoding

ASCII defines 7-bit/8-bit numeric codes for English letters, numbers, and symbols:

Character 'A' Number 65 01000001₂

10. Unicode — Encompassing Every Human Language

ASCII was limited to English. For global languages—Bengali, Chinese (你好), Arabic (مرحبا), Japanese (こんにちは), plus emojis (🚀)—computing created Unicode.

UTF-8 Encoding

UTF-8 is the universal encoding of the modern web. It is variable-length (1 to 4 bytes per character) and fully backward compatible with ASCII.

11. How Images Become Binary

A computer raster image is made of microscopic squares called Pixels. In the standard RGB (Red, Green, Blue) model, each pixel has 3 color channels (0 to 255):

Red = 255
Green = 0
Blue = 0
Color RGB Values Numbers Binary

12. Image Resolution and Size

In a standard 1920 × 1080 Full HD image:

1920 × 1080 = 2,073,600 Pixels (~2 Megapixels)

With 3 bytes (24 bits) per pixel for RGB, uncompressed raw storage would require roughly 6.2 MB for just a single still frame!

13. Image Compression (JPEG)

Raw pixel grids are too large for storage and transmission. JPEG uses mathematical transforms to discard subtle details imperceptible to human eyes (lossy compression):

Image → Pixels → Matrix Math → Compression Encoding → Compact Binary File

14. How Audio Becomes Binary

A microphone converts continuous acoustic sound pressure into an analog electrical voltage. Analog-to-Digital converters (ADC) transform it into bits:

Analog Wave Sampling Quantized Numbers Binary
Sampling Rate (e.g. 44.1 kHz):

The wave's voltage is measured 44,100 times every second (standard CD quality).

Bit Depth (e.g. 16-bit / 24-bit):

The precision allocated to store each amplitude measurement.

15. How Video Becomes Binary

Video is a synchronized rapid sequence of image frames paired with multichannel audio (e.g., 30 FPS = 30 still images per second):

Video Frame → Pixels → Color values → Matrix math → Binary stream
Audio Track → Continuous acoustic wave → Samples → Binary stream

16. Computer Programs Are Data Too

Data is not restricted to static files like photos or songs. Executable applications are also stored as binary data:

Source Code Machine Instructions Binary Opcodes CPU Processing

17. Identical Bits, Different Meanings

Suppose memory contains the byte: 01000001

A Profound Computing Truth

Bits possess zero inherent meaning on their own. Meaning arises entirely from Interpretation + Context + Format.

Interpreted as text, it is the letter 'A'. As an integer, it is 65. As pixel data, it could be an intensity level of red.

18. What Is a File?

A file is a structured container of bytes stored with a defined metadata format so software knows how to parse it:

Raw Bits + Format Specification + Software Parser = Meaningful Content

19. Why Compression Is Critical

Lossless Compression:

Decompresses back into the original bits with 100% mathematical fidelity (e.g. ZIP, PNG, FLAC).

Lossy Compression:

Discards redundant perceptual data to achieve radical size reductions (e.g. JPEG, MP3, MP4, WebP).

20. Data at Global Scale

From a 1 KB text note to the exabytes of video housed in YouTube datacenters, all modern digital civilization rests on this identical foundation of bits and bytes.

21. The Complete Journey: From Camera Flash to Storage

Light Sensor Voltages Pixels Compression File Bytes Bits Storage

22. Where Do Bits Physically Live?

Bits are not physical characters carved into chips. In flash SSDs, they are trapped electrons altering the voltage conductivity of microscopic floating-gate transistors.

23. Abstraction — The Core Principle of Computing

Abstraction hides overwhelming physical complexity behind intuitive higher-level interfaces:

Electrons Transistor Logic Gate CPU Operating System Application / UI

24. From Bits to Artificial Intelligence

Even multi-billion-parameter neural networks and Large Language Models consist fundamentally of matrix weight matrices stored and computed as floating-point binary bits.

🧠 Key Takeaways

  1. A Bit is a binary digit — 0 or 1.
  2. 1 Byte = 8 bits (256 combinations).
  3. A group of n bits produces 2ⁿ possible combinations.
  4. Numbers, Text (Unicode/UTF-8), Images (RGB Pixels), Audio, and Video are all digital data.
  5. Software program instructions are also stored as digital data.
  6. Bits have no intrinsic meaning; format and interpretation create meaning.
  7. Abstraction enables developers to create software without manually managing electrons.
🚀 Next Lesson

Lesson 05 — Transistors: The Smallest Electronic Switch in the World

How are 0 and 1 physically generated inside silicon?

Electricity Voltage Transistor ON/OFF 0/1

Next, our hardware construction begins: Transistor → Logic Gate → Circuit → Adder → ALU → CPU → Computer.