A bit on its own means nothing. It is the agreement about what the bits mean that turns them into a letter, a colour or a note. The exact same byte 01000001 is the number 65, the letter A, a very dark red, or a fragment of a machine instruction — and which one it is depends entirely on what the program reading it expects. That is the whole idea of encoding.
Bits, bytes and the prefix problem
A bit (b) is one 0 or 1. Eight bits make a byte (B), which is the smallest unit most systems address individually. From there the prefixes climb, but there are two competing sets of them, and that difference is the source of a question that shows up in every course like this one.
- 1 kB = 1 000 bytes
- 1 MB = 1 000 000 bytes
- 1 GB = 1 000 000 000 bytes
- Used by: drive manufacturers, network speeds, the SI standard
- 1 KiB = 1 024 bytes ()
- 1 MiB = 1 048 576 bytes ()
- 1 GiB = 1 073 741 824 bytes ()
- Used by: RAM sizing, Windows file sizes, operating systems
Text: ASCII and Unicode
ASCII assigns a number from 0 to 127 to each English character, which fits in 7 bits (stored in one byte). The layout is deliberate: 'A' is 65 and 'a' is 97, exactly 32 apart, so flipping one bit changes case. Digits start at 48, so subtracting 48 from the code of a digit character gives the number it represents — a trick you will use when reading input from a serial port.
ASCII covers English and nothing else, which is why Unicode exists. Unicode assigns a number (a code point) to every character in every writing system, plus emoji. UTF-8 is the encoding that stores those code points using one to four bytes each, with the first 128 deliberately identical to ASCII — so every ASCII file is already a valid UTF-8 file. This is why a plain English text file and a file full of emoji can have very different sizes for the same number of characters.
Images, colour and sound
An uncompressed image is a grid of pixels, each storing a colour. Colour depth is how many bits each pixel gets: 8-bit gives 256 colours, 24-bit gives 8 bits each for red, green and blue, which is 16.7 million colours. File size follows directly from multiplication — width × height × depth — and this is the calculation you are most likely to be asked to perform.
Sound works the same way in one dimension instead of two. An analog waveform is sampled thousands of times a second, and each sample is stored as a number. CD audio uses 44 100 samples per second, 16 bits per sample, two channels. Higher sample rate captures higher frequencies; higher bit depth captures quieter detail. Both increase file size proportionally.
| Data type | What is stored | Size driver |
|---|---|---|
| Text (ASCII) | One byte per character | Number of characters |
| Text (UTF-8) | 1–4 bytes per character | Which characters are used |
| Bitmap image | One colour value per pixel | Width × height × colour depth |
| Audio (PCM) | One number per sample per channel | Sample rate × bit depth × channels × seconds |
| Video | Many images per second | Frame size × frame rate × duration |