Text file size calculation
Representation of text, images and sound
Text file size calculation
Representation of text, images and sound
byte
a group of 8 bits
number prefix
a word used in front of a number to represent a multiple of that number
encoding
putting a sequence of characters into an agreed format
file size
a measure of how much binary data a file contains
I can calculate and compare the file size of text data when different encoding methods are used.
Compare quantities of data
Text file size calculation
Calculate and compare text file sizes
A bit is a single binary digit (0, 1). Bits are used to
represent all data in computers.
Compare quantities of data
Data represented in binary can result in large sequences
of bits.
1101010110001110100111011001101100010110001010110010110101110001
Compare quantities of data
We group collections of bits into smaller sections to
make them them easier to read and compare.
These groups are the units used to measure data storage.
A group of 8 bits is referred to as a byte.
Compare quantities of data
A sequence of 32 bits could therefore be counted as 4 bytes.
A binary sequence is 16 bits long. How many bytes is this?
1
3
2
4
Sequences of data can become too large to express meaningfully, even using bytes.
Compare quantities of data
Jacob
My computer says the file for my homework is
3 290 000 bytes. Is that
a lot?
Sam
I have a photo on my phone and it says it’s 4.21 megabytes. I’m not sure.
Number prefixes help us express multiples of a number.
This makes it easier to understand and compare sizes.
Compare quantities of data
In computing, bytes are summarised in multiples of 1000.
Compare quantities of data
Sort into ascending order -Smallest at the top
Petabyte
Kilobyte
Megabyte
Gigabyte
Terabyte
1 megabyte = 1 000 000 bytes
3 290 000 ÷ 1 000 000 = 3.29 megabytes
Compare quantities of data
Jacob
My computer says the file for my homework is
3 290 000 bytes. Is that
a lot?
Sam
I have a photo on my phone and it says it’s 4.21 megabytes. I’m not sure.
Compare quantities of data
Text file size calculation
Calculate and compare text file sizes
Calculate and compare text file sizes
Either ASCII or Unicode standards can be used to
encode text characters.
ASCII uses 7 bits to represent each character. Unicode uses either 16 or 32 bits depending on the version being used.
Unicode is able to represent a wider range of characters than ASCII, but this has the effect of increasing the storage required for identical characters.
Calculate and compare text file sizes
Consider the text “ASCII and Unicode encode text.”
There are 30 characters to represent including the spaces and the full stop.
If ASCII encoding is used, each character requires 7 bits for
its representation.
Therefore, the total
file size to store this text would be 7 ✕ 30 = 210 bits
210 bits / 8 = 26.25 bytes
In bytes, what is the file size of an ASCII text file with
the text “password” in it?
7 bytes
56 bytes
8 bytes
120 bytes
Calculate and compare text file sizes
If 32-bit Unicode encoding is used, each character requires 32 bits for its representation.
Therefore, the total
file size to store this text would be 32 ✕ 30 = 960 bits
960 bits/ 8 = 120 bytes
Calculate and compare text file sizes
Aisha
32-bit Unicode requires 4 bytes per character. I can just count the characters and multiply by 4 to find the file size.
4 ✕ 30 = 120 bytes.
In bytes, what is the file size of a 16-bit Unicode text
file with the text “password” in it?
8
16
128
32
Calculate and compare text file sizes
ASCII encoding results in smaller file sizes for text files.
Unicode encoding results in larger file sizes for text files.
ASCII encoding has a smaller character set so can only represent a limited number of characters.
Unicode encoding has a larger character set so is able to represent a wider range of characters.
Worksheet - 15 minutes
Calculate and compare text file sizes
Complete the table to show how the file sizes of text files change when different encoding methods are used.
Calculate and compare text file sizes
A low-cost smartwatch is being developed. The developers want
to include an English dictionary on it.
There are 126 000 000 characters in the dictionary file. What would the file size of the dictionary be in megabytes if ASCII encoding is used?
1 character = 7 bits therefore 126 000 000 characters is 882 000 000 bits (882 000 000 ÷ 8) 110 250 000 bytes
1 megabyte = 1 000 000 bytes
So, 110 250 000 ÷ 1 000 000 = 110.25 megabytes
Calculate and compare text file sizes
What would the file size of the dictionary be in
megabytes if 16-bit Unicode encoding is used?
1 character = 16 bits or 2 bytes
Therefore 126 000 000 characters is 252 000 000 bytes
1 megabyte = 1 000 000 bytes
So, 252 000 000 ÷ 1 000 000 = 252 megabytes
Calculate and compare text file sizes
c. The amount of storage the smartwatch has affects the final cost. Explain why encoding the dictionary using ASCII is the best choice in this case.
The ASCII character set is limited to 128 characters. Emojis are not included in this. Unicode provides more characters, including emojis.
ASCII uses fewer bits per character than Unicode and will therefore require less storage on the smartwatch.
d. The creators of the smartwatch would like to include an appendix to the dictionary providing definitions for different emojis. Explain why ASCII would no longer be suitable.
Calculate and compare text file sizes
The developers decide to use 32-bit Unicode.
How much additional storage is needed compared to ASCII? Describe what this will mean for the cost of the smartwatch.
ASCII uses 7 bits per character, whereas 32-bit Unicode uses 4 bytes
per character.
ASCII requires 110.25 megabytes.
32-bit Unicode requires:
126 000 000 characters x 4 bytes ÷ 1 000 000 = 504 megabytes
Unicode therefore requires approximately 4.5 times the amount of storage space and this will increase the cost of the smartwatch.
Key voacabulary - Fill in the blanks
A byte is equivalent to 8 bits.
Number prefixes are used to summarise multiples of a number for easier comparison.
Different text encoding schemes use different amounts of bits to represent each character.
File size measures the amount of binary data and is summarised using bytes and number prefixes.
I can calculate and compare the file size of text data when different encoding methods are used.