Skip to content
Study Hall
Lesson 3 of 4Introduction to Computers
Unit 1 · Lesson 3 of 4

Representing Data: Bits, Bytes and Files

How text, colours, sound and file sizes are all built out of the same bits — and why a 500 GB drive shows up as 465 GB.

4 min read10 practice questionsAsk AI about this →

Key things to remember

  1. 18 bits = 1 byte. Lowercase b means bits, uppercase B means bytes.
  2. 21 KiB = 1024 B, but 1 kB = 1000 B. Drive makers use the second; operating systems often label the first as "GB".
  3. 3ASCII: 'A' = 65, 'a' = 97, '0' = 48. The gap between upper and lower case is always 32.
  4. 4Image size in bits = width × height × colour depth; divide by 8 for bytes.
  5. 5-bit colour depth gives colours; 24-bit gives 8 bits per RGB channel = 16.7 million.
  6. 6Lossless compression is reversible; lossy compression permanently discards data.

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.

Storage marketing uses powers of 10; memory uses powers of 2.bit (b)1one 0 or 1byte (B)8 bitsone ASCII characterkilobyte (KB)1 000 Ba short emailmegabyte (MB)1 000 KBa phone photogigabyte (GB)1 000 MBa movieterabyte (TB)1 000 GBa laptop drive1 KiB = 1024 B. A "500 GB" drive shows as about 465 GiB in Windows — no bytes went missing.
Fig 1The units, and what each one holds in practice.

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.

ADecimal prefixes (powers of 10)
  • 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
BBinary prefixes (powers of 2)
  • 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
Why a 500 GB drive looks like 465 GB
The manufacturer sold you 500 000 000 000 bytes, which is honest. Windows divides by 1 073 741 824 instead of 1 000 000 000 and labels the result "GB" when it really means GiB. 500 000 000 000 ÷ 1 073 741 824 ≈ 465.7. No bytes went missing — two different definitions of the same abbreviation were used.
Bits vs. bytes: the capital letter matters
b is bits, B is bytes. Network speeds are quoted in bits per second (Mb/s), file sizes in bytes (MB). A 100 Mb/s connection downloads at 100 ÷ 8 = 12.5 MB/s at best. Miss the factor of 8 and every transfer-time answer is off by 800%.

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.

Text is stored as numbers; the number-to-glyph map is the encoding.characterASCII codeone byte of binaryH7201001000i10501101001!3300100001A = 65a = 970 = 48ASCII covers 128 characters in 7 bits. Unicode (UTF-8) extends this to every writing systemusing 1–4 bytes per character, while keeping the first 128 codes identical to ASCII.
Fig 2Text stored as numbers, then as bits.

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.

Divide by 8 for bytes, then by 1 000 000 for MB.

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 typeWhat is storedSize driver
Text (ASCII)One byte per characterNumber of characters
Text (UTF-8)1–4 bytes per characterWhich characters are used
Bitmap imageOne colour value per pixelWidth × height × colour depth
Audio (PCM)One number per sample per channelSample rate × bit depth × channels × seconds
VideoMany images per secondFrame size × frame rate × duration
Compression
Real files are almost always compressed. Lossless compression (ZIP, PNG, FLAC) rebuilds the original exactly by removing redundancy. Lossy compression (JPEG, MP3, H.264) permanently discards detail people are unlikely to notice, achieving far smaller files. Once discarded, that detail cannot be recovered — which is why re-saving a JPEG repeatedly degrades it.

Worked examples

Reveal one step at a time and try to beat it to the next line.

Example 1
An uncompressed image is 1024 × 768 pixels at 24-bit colour depth. Find its size in megabytes (1 MB = 1 000 000 bytes).
Example 2
How long does it take to download a 1.5 GB file over a 50 Mb/s connection running at full speed? (1 GB = 1000 MB.)
Example 3
A CD stores stereo audio at 44 100 samples per second, 16 bits per sample. How many megabytes does one minute of audio take?

Where marks get lost

  • Forgetting the factor of 8 when a file size (bytes) meets a link speed (bits per second).
  • Multiplying an image's pixel count by the colour depth and calling the result bytes — it is bits until you divide by 8.
  • Assuming 1 MB = 1024 KB in a question that defines 1 MB = 1 000 000 bytes. Use the definition the question gives.
  • Thinking a drive that reports less capacity than advertised is faulty or has hidden partitions — it is the kB/KiB labelling difference.
  • Believing lossy compression can be undone by re-saving at higher quality. The discarded detail is gone permanently.

Flashcards 9

Bit vs. byte
1 KiB vs. 1 kB
ASCII code for 'A' and 'a'
ASCII code for the character '0'
+ 5 more

Practice

1
An image is 800 × 600 pixels at 16-bit colour. What is its size in bytes?
bytes
2
How many seconds does a 400 MB file take to download over a 25 Mb/s link?
s
3
A drive is sold as 2 TB but Windows reports 1.82 TB. What is the explanation?
4
The ASCII code for 'C' is 67. What is the ASCII code for 'c'?
5
How many distinct colours can a pixel with 8-bit colour depth display?
6
A file is compressed and later restored byte-for-byte identically. What type of compression was used?
7
How many bytes does the ASCII string "TEJ3M" occupy, with no terminator?
bytes
8
Why does a photo of a blue sky compress to a much smaller JPEG than a photo of gravel, at the same resolution?
9
Match each quantity to its correct unit.
Internet connection speed
File size on disk
Colour depth
Audio sample rate
10
How many bits are in 3 KiB? (1 KiB = 1024 bytes)
bits

Spot a mistake on this page? Let us know