- Use N = 2ⁱ to find how many bits are needed to encode N options
- Calculate the information volume of a message with I = K · i and find the power of an alphabet
- Convert between bits, bytes, KB, MB and GB with powers of two, and add and match mixed units
- Find the size of a document with text and pictures and the transfer time with I = v · t
Leyla’s phone says: “Storage: 128 GB, free: 5 GB”. One photo takes about 3 MB. How many more photos will fit? How many seconds will a 2 MB file from a friend take to download? To answer, you need to know the units information is measured in and how to convert between them.
In the lesson “Information, its kinds and information processes” we learned what information is; now we will measure it with numbers. Azerbaijan’s university entrance exam (DİM) always checks this topic: in each of the four entrance exams held in 2025 and 2026, 3 of the 30 informatics tasks were on encoding information and its units, and in three of them the coded-answer task 87 asked you to match information volumes.
The bit and the formula N = 2ⁱ
Inside a computer all information — text, pictures and music alike — is stored as signals with only two states: there is a voltage or there is not; a spot on a disk is magnetized one way or the other. We write these two states as the digits 1 and 0.
The smallest unit of information: one digit of a binary code (0 or 1). One bit tells which of two equally likely options has happened. The name comes from binary digit.
One bit tells 2 options apart: 0 and 1. Two bits give 4 options: 00, 01, 10, 11. Three bits give 8, from 000 to 111. Every new bit doubles the number of options, because each old code can be preceded once by 0 and once by 1. So i bits can make 2ⁱ different codes.
- Nthe number of different options being encoded (symbols, colors, levels…); for an alphabet, the power of the alphabet
- ithe number of bits in the code of one option — the amount of information one option (symbol) carries
i bits give 2ⁱ different codes. If N is known, i = log₂N; if N is not a power of two, round i up.
| i | 2ⁱ | i | 2ⁱ |
|---|---|---|---|
| 1 | 2 | 9 | 512 |
| 2 | 4 | 10 | 1024 |
| 3 | 8 | 11 | 2048 |
| 4 | 16 | 12 | 4096 |
| 5 | 32 | 13 | 8192 |
| 6 | 64 | 16 | 65,536 |
| 7 | 128 | 20 | 1,048,576 |
| 8 | 256 | 24 | 16,777,216 |
N is not always a power of two. To number 30 students, 4 bits are too few (2⁴ = 16) and 5 bits are enough (2⁵ = 32). In such cases i is the smallest whole number with 2ⁱ ≥ N, that is, 2ⁱ⁻¹ < N ≤ 2ⁱ. Some codes (32 − 30 = 2) stay unused, but there is no such thing as half a bit.
1) A class has 30 students. What is the smallest number of bits that gives every student a separate binary code?
2) How many bits are needed to encode the 3 signals of a traffic light (red, yellow, green)?
3) What is the smallest number of bits needed to encode 100 different colors?
4) A code is 6 bits long. At most how many different objects can it encode?
Show solutionHide solution
2) 2¹ = 2 < 3 ≤ 4 = 2² ⇒ 2 bits (one code, for example 11, stays unused).
3) 2⁶ = 64 < 100 ≤ 128 = 2⁷ ⇒ 7 bits.
4) N = 2⁶ = 64 objects.
The same formula gives the amount of information in a message. If an event has N equally likely outcomes, a message telling which one happened carries i bits, where N = 2ⁱ. A coin toss has two equally likely outcomes, so the message “which side came up” is 1 bit (N = 2), while “the ball is in box 11 of 16” is 4 bits (16 = 2⁴).
1) A station has 8 tracks. How many bits of information are in the message “The train arrives on track 5”?
2) A piece stands on one of the 64 squares of a chessboard. How many bits is the message that tells its square?
3) A message carries 5 bits of information. It names one of how many equally likely options?
4) Elvin thinks of a number from 1 to 128. Aysel may only ask yes/no questions. At least how many questions guarantee that she finds the number?
Show solutionHide solution
2) 64 = 2⁶ ⇒ 6 bits.
3) N = 2⁵ = 32 options.
4) Each answer halves the options, that is, it gives 1 bit: 128 → 64 → 32 → 16 → 8 → 4 → 2 → 1. 128 = 2⁷ ⇒ 7 questions.
From bytes to terabytes: units and powers of two
Eight bits make 1 byte: one byte can hold 2⁸ = 256 different values (from 0 to 255). Larger units differ from each other by a factor of 1024 = 2¹⁰: kilobyte, megabyte, gigabyte, terabyte (KB, MB, GB, TB). Azerbaijani textbooks and DİM tasks write them as Kbayt, Mbayt, Gbayt, Tbayt.
| Unit | In bytes | In bits |
|---|---|---|
| 1 byte | 1 | 8 = 2³ bits |
| 1 KB | 1024 = 2¹⁰ bytes | 2¹³ bits |
| 1 MB | 1024 KB = 2²⁰ bytes | 2²³ bits |
| 1 GB | 1024 MB = 2³⁰ bytes | 2³³ bits |
| 1 TB | 1024 GB = 2⁴⁰ bytes | 2⁴³ bits |
- 2³ = 8the factor between a byte and a bit
- 2¹⁰ = 1024the factor between neighboring units (byte → KB → MB → GB)
In bits the exponents are 3, 13, 23, 33, 43: each next unit adds 10 to the exponent.
- 1Write the numbers with powers of two
For example: 512 = 2⁹, 48 = 3 · 2⁴, 160 = 5 · 2⁵, 96 = 3 · 2⁵.
- 2Convert the unit into bits
byte → · 2³, KB → · 2¹³, MB → · 2²³, GB → · 2³³.
- 3Add or subtract the exponents
When multiplying, add the exponents: 2ᵃ · 2ᵇ = 2ᵃ⁺ᵇ; when dividing, subtract them: 2ᵃ ÷ 2ᵇ = 2ᵃ⁻ᵇ.
- 4Go to the unit you need
Divide the number of bits by the size of that unit in bits: by 2²³ for MB, by 2¹³ for KB.
1) 20 · 2²⁵ bits = ? MB
2) 96 · 2¹⁸ bytes = ? MB
3) 48 · 2¹⁴ KB = ? MB = ? GB
4) 2³⁶ bits = ? GB
Show solutionHide solution
2) 96 · 2¹⁸ bytes = 96 · 2²¹ bits; 96 · 2²¹ ÷ 2²³ = 96 ÷ 4 = 24 MB. Shortcut: from bytes to MB divide by 2²⁰: 96 · 2¹⁸ ÷ 2²⁰ = 24.
3) KB → MB: divide by 2¹⁰: 48 · 2¹⁴ ÷ 2¹⁰ = 48 · 16 = 768 MB; 768 ÷ 1024 = 0.75 GB.
4) 2³⁶ ÷ 2³³ = 2³ = 8 GB.
The phone has 5 GB of free space. One photo takes 3 MB. At most how many photos will fit?
Show solutionHide solution
5120 ÷ 3 = 1706.66… Part of a photo cannot be saved, so take the whole part: 1706 photos.
1) 1 GB + 1536 MB + 2²¹ KB = ? GB
A) 3 B) 4 C) 4.5 D) 2.5 E) 3.5
2) 3 KB + 1024 bytes + 2¹³ bits = ? KB
3) 256 bytes + 6144 bits = ? KB
Show solutionHide solution
1 + 1.5 + 2 = 4.5 GB (C).
2) 1024 bytes = 1 KB and 2¹³ bits = 1 KB ⇒ 3 + 1 + 1 = 5 KB.
3) 6144 bits = 6144 ÷ 8 = 768 bytes; 256 + 768 = 1024 bytes = 1 KB.
Match the quantities.
1. 2²⁶ bits
2. 40 · 2¹⁷ bytes
3. 3 · 2¹² KB
a. 5 MB
b. 3 · 2²² bytes
c. 8 MB
d. 2¹³ KB
e. 12 MB
Show solutionHide solution
1. 2²⁶ ÷ 2²³ = 2³ = 8 MB; item d is also 2¹³ KB = 2¹³ ÷ 2¹⁰ = 8 MB ⇒ c, d.
2. 40 · 2¹⁷ ÷ 2²⁰ = 40 ÷ 8 = 5 MB ⇒ a.
3. 3 · 2¹² ÷ 2¹⁰ = 3 · 4 = 12 MB; item b is also 3 · 2²² ÷ 2²⁰ = 12 MB ⇒ b, e.
Answer: 1 – c, d; 2 – a; 3 – b, e. Careful: one number may match two letters, so check every letter.
The alphabet approach: I = K · i
The number N of all symbols in the alphabet a message is written in: letters, digits, punctuation marks, the space and so on. Each symbol of an N-symbol alphabet is encoded with i bits, where N = 2ⁱ.
Here the computer ignores the meaning of a text and simply counts symbols: “hello” and “qwert” are both 5 symbols. If every symbol takes i bits, a message of K symbols takes K · i bits. This number is the information volume of the message.
- Ithe information volume of the message (bits)
- Kthe number of symbols in the message
- ithe information volume of one symbol (bits); N = 2ⁱ
For a text of several pages, K = pages · lines per page · symbols per line.
1) Find the volume in bits and bytes of a 120-symbol message written in a 64-symbol alphabet.
2) An alphabet has 26 letters, 10 digits, 5 punctuation marks and the space. How many bytes is a 200-symbol message in this alphabet?
3) A 2-page text has 32 lines per page and 64 symbols per line; the power of the alphabet is 256. How many KB is the text?
Show solutionHide solution
2) N = 26 + 10 + 5 + 1 = 42; 2⁵ = 32 < 42 ≤ 64 = 2⁶ ⇒ i = 6 bits.
I = 200 · 6 = 1200 bits = 1200 ÷ 8 = 150 bytes.
3) K = 2 · 32 · 64 = 2¹ · 2⁵ · 2⁶ = 2¹² symbols; 256 = 2⁸ ⇒ i = 8 bits.
I = 2¹² · 2³ = 2¹⁵ bits = 2¹⁵ ÷ 2¹³ = 4 KB.
1) A 160-symbol message has a volume of 100 bytes. Find the power of the alphabet.
2) A message of 2048 symbols has a volume of 1 KB. What is the power of the alphabet?
3) Two messages have 300 symbols each. The first uses a 16-symbol alphabet, the second a 256-symbol alphabet. By how many bytes is the second message larger?
Show solutionHide solution
2) I = 2¹³ bits, K = 2048 = 2¹¹ ⇒ i = 2¹³ ÷ 2¹¹ = 2² = 4 bits ⇒ N = 2⁴ = 16.
3) i₁ = 4 bits, i₂ = 8 bits. Difference: 300 · (8 − 4) = 1200 bits = 1200 ÷ 8 = 150 bytes.
In real texts every symbol is encoded with a code table: 1 byte in ASCII, 2 bytes in UNICODE. The next lesson, “Encoding text”, is about this.
The size of a document and transfer time
Documents contain pictures as well as text. The size of a document is the sum of its parts: the text part is found with I = K · i, and the size of a picture is either given in the task or calculated with the formula from the lesson “Computer graphics: encoding raster and vector images”. Bring all parts to the same unit before adding.
A 40-page booklet has 32 lines per page and 64 symbols per line; the text uses a 128-symbol alphabet. In addition, 8 of the pages each hold a 12 KB picture. Find the information volume of the booklet in KB.
A) 176 B) 70 C) 166 D) 96 E) 550
Show solutionHide solution
One page: 7 · 2¹¹ bits = 7 · 2¹¹ ÷ 2¹³ = 7/4 = 1.75 KB; 40 pages: 40 · 1.75 = 70 KB.
Pictures: 8 · 12 = 96 KB.
Total: 70 + 96 = 166 KB (C).
The wrong options are typical mistakes: A — taking i = 8, B — forgetting the pictures, D — forgetting the text, E — counting a picture on all 40 pages.
Each page of a 128-page document has x symbols and one 4 KB picture. Every symbol is encoded with 8 bits, and the whole document is 640 KB. Find x.
Show solutionHide solution
Divide both sides by 128: x bytes + 4 KB = 5 KB ⇒ x bytes = 1 KB = 1024 bytes.
Answer: x = 1024 symbols.
When you send or download a file, the time depends on the file size and on the transfer rate of the communication channel. The rate is the number of bits sent per second, measured in bit/s.
- Ithe volume of information sent (bits)
- vthe transfer rate (bit/s)
- tthe transfer time (s)
Hence t = I / v and v = I / t. First convert the volume into bits and the time into seconds.
1) How many seconds does it take to send a 2 MB file at 2²⁰ bit/s?
2) A 3-page text has 40 lines per page and 64 symbols per line, 8 bits per symbol. How many minutes does it take to send it at 1024 bit/s?
3) A channel works at 512 bit/s. How many KB can it send in 3 minutes?
4) A file takes 64 seconds over a 2048 bit/s channel. How long does it take over an 8192 bit/s channel?
Show solutionHide solution
2) I = 3 · 40 · 64 · 8 = 61,440 bits; t = 61,440 ÷ 1024 = 60 s = 1 min.
3) t = 3 · 60 = 180 s; I = 512 · 180 = 92,160 bits = 92,160 ÷ 8 = 11,520 bytes = 11,520 ÷ 1024 = 11.25 KB.
4) The volume is the same and the rate is 8192 ÷ 2048 = 4 times higher, so the time is 4 times shorter: 64 ÷ 4 = 16 s. No big multiplications needed.
KB, MB, GB = 2**13, 2**23, 2**33 # bits in 1 KB, 1 MB, 1 GB
print((1*GB + 1536*MB + 2**21*KB) / GB)
print(2**26 / MB, 40 * 2**17 * 8 / MB, 3 * 2**12 * KB / MB)
pages, lines, chars, i = 40, 32, 64, 7
text = pages * lines * chars * i / KB
print(text, text + 8 * 12)▸ Expected output
4.5 8.0 5.0 12.0 70.0 166.0
2**13 means 2¹³, the number of bits in 1 KB. The program recalculates the sum, matching and booklet problems above.- 1.5 KB = bytes
- 2.3 MB = KB
- 3.4096 bits = bytes
- 4.2¹⁶ bits = KB
- 5.One symbol of a 64-symbol alphabet takes bits
- 6.Naming one of 100 equally likely options needs at least bits
Key points
- The bit is the smallest unit of information (0 or 1); i bits give N = 2ⁱ different codes.
- If N is not a power of two, round i up: 2ⁱ⁻¹ < N ≤ 2ⁱ (100 options → 7 bits).
- A message of K symbols has the volume I = K · i; i comes from the power of the alphabet: N = 2ⁱ.
- 1 byte = 2³ bits, 1 KB = 2¹⁰ bytes = 2¹³ bits, 1 MB = 2²³ bits, 1 GB = 2³³ bits.
- Bring mixed units to one unit before adding or comparing; in a matching task one item may match several letters.
- Transfer time: t = I / v; convert the volume into bits and the time into seconds.
Check yourself
12 questions. Every correct answer earns XP.