Underneath every program, all data — numbers, text, images, video — is stored as sequences of just two values: 0 and 1. Understanding bits and bytes is understanding what a computer is actually doing beneath the code you write.
A bit (short for "binary digit") is the smallest unit of data a computer can store — a single 0 or 1. On its own, a bit can represent exactly two states: off/on, false/true, no/yes.
A byte is a group of 8 bits. One byte can represent 2⁸ = 256 different values (0 to 255) — enough to store, for example, a single letter of English text using a common encoding.
| Unit | Size | Roughly |
|---|---|---|
| 1 byte | 8 bits | One character |
| 1 kilobyte (KB) | 1,024 bytes | A short email |
| 1 megabyte (MB) | 1,024 KB | A few photos |
| 1 gigabyte (GB) | 1,024 MB | A couple of movies |
Data types have sizes for this exact reason — a data type that only needs to hold true/false doesn't need to reserve as much memory as one holding a large number. As a beginner you rarely manage bits directly, but the concept underlies everything from file sizes to network speed to why some numbers in code have limits.