ScholaFly

CS02-05 Computer Science Watch

Working out the size of a text file

Watch on YouTube

In this lesson

In this video you'll learn about working out the size of a text file for GCSE Computer Science. Watch first: {{video:CS02-01}}, {{video:CS02-02}}

By the end: Calculate the size of a text file from the bits per character and the number of characters, convert the answer into sensible units, and work out the storage capacity required for a set of files.

What it covers

  • Text file size in bits = bits per character x number of characters (OCR prints this formula and it is NOT given in the exam)
  • Which bit count to use, per board - 7 for AQA and Edexcel, 8 in an OCR exam - taken as settled from CS02-02, not re-argued
  • Bits to bytes is DIVIDE BY 8, and it is a separate step from the prefix step - two divisions, never one
  • Converting the result into kilobytes or megabytes on AQA and OCR, and into kibibytes or mebibytes on Edexcel
  • Storage capacity for a SET of files: work out one, then multiply by how many
  • Showing working, because the marks sit in the steps and not only in the final number
  • One line on metadata: OCR states that an allowance for metadata in calculations may be used, so a real file is slightly bigger than the characters alone

Key words

About this video

Working out the size of a text file | GCSE Computer Science

How to work out the size of a text file from characters and bits per character, convert to kB or MB, and find storage for many files.
AQA 8525, Edexcel 1CP2 and OCR J277 GCSE. Units and file sizes 5 of 6.
Full Units and file sizes playlist: https://www.youtube.com/playlist?list=PLO0-7kcru9G8
More at https://scholafly.com

Watch first: Bits, bytes and the units of storage - https://youtu.be/6NVNIeA80bU, Character Sets and ASCII (Character Encoding) - https://youtu.be/zD9_Zs-lSWE
Video code: CS02-05 (search "ScholaFly CS02-05")

Videos in this chapter:
CS02-00 Units, characters and file size - Intro: https://youtu.be/09-qBlPgybs
CS02-01 Bits, bytes and the units of storage: https://youtu.be/6NVNIeA80bU
CS02-02 Character sets and ASCII: https://youtu.be/zD9_Zs-lSWE
CS02-03 Character codes run in order: https://youtu.be/Oz94XpnG-qA
CS02-04 Unicode: https://youtu.be/8UPCwLqs3PI
CS02-05 Working out the size of a text file: https://youtu.be/3QQuoX_vSSQ
CS02-06 The limits of a fixed number of bits: https://youtu.be/acUh8FmOLcw

#GCSEComputerScience #UnitsAndFileSizes

For teachers
This GCSE Computer Science lesson teaches working out the size of a text file. By the end, students should be able to calculate the size of a text file from the bits per character and the number of characters, convert the answer into sensible units, and work out the storage capacity required for a set of files. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.

Exam board specification references:
AQA GCSE Computer Science (8525)
- 3.3.3 State that a bit is the fundamental unit of information and a byte is 8 bits, use the decimal prefixes kilo, mega, giga and tera, and compare quantities of bytes.
Pearson Edexcel Level 1/Level 2 GCSE (9-1) in Computer Science
- 2.3.1 Data storage and compression
Cambridge OCR Level 1/Level 2 GCSE (9-1) in Computer Science
- 1.2.3 Units

Read the transcript

Picture a phone company storing a hundred million text messages. Each one is a hundred and sixty characters long, and every character is stored in eight bits. How many gigabytes does all of that fill? It takes four short steps, and none of them needs a calculator. The same four steps work on any text file, so start with one small file, and come back to the messages at the end.

You are watching video five of six in Units, characters and file size, and it spends what the first two videos built. If the units are wobbly, Bits, bytes and the units of storage is the place to start.

A text file stores one code for every character in it. So its size depends on two numbers: how many characters there are, and how many bits each one takes. Images and sound have formulas of their own, and the video Working out image and sound file sizes does those. This one is text only. Here is the formula. File size in bits equals bits per character, times the number of characters. Bits per character is the width of each code. The number of characters counts every letter, space and punctuation mark. Learn the formula, because a question may not print it for you. That multiplication is the first of four steps, always in the same order. Times the bits. Divide by eight. How many of them. Then the unit step. First file: two thousand four hundred characters, each stored in eight bits, with the size wanted in kilobytes. Step one, times the bits. Two thousand four hundred characters, times eight bits each, is nineteen thousand two hundred bits. That number is a count of bits, and a file is kept in bytes. Nineteen thousand two hundred bits: what is the next step, and what does it give? Divide by eight, because a byte is eight bits. Nineteen thousand two hundred, divided by eight, is two thousand four hundred bytes. Eight bits per character means one byte per character, which is why the bytes match the characters here. Step three, how many of them: one file, so times one. Last comes the unit step. Two thousand four hundred bytes, divided by a thousand, is two point four kilobytes. Two point four kilobytes, from two separate divisions, with every line labelled by its unit. Now a different student's working for that same file. Nineteen thousand two hundred bits, divided by a thousand, gives nineteen point two kilobytes. The arithmetic in that line is fine, and the result is still marked wrong. What has gone wrong in that student's working, and where? Divide by eight is missing. A thousand bits is a kilobit, not a kilobyte, so nineteen point two is eight times too big. One examiner's report, on a question about the size of an image file, lists this among the common errors: dividing by one thousand in an attempt to convert to kilobytes rather than dividing by eight to convert the total number of bits into bytes. That question was about an image, and the slip is the same on any file. Bits went straight to kilobytes instead of through bytes. The habit is two divisions, never one: divide by eight to reach bytes, and only then take the unit step. Try a fresh file: five thousand characters at eight bits each. Its four lines of working are scrambled: five kilobytes, forty thousand bits, five thousand bytes, and five thousand times eight. Each line is worked out from the one before it, so only one order works. Which order do those four lines go in, from top to bottom? Five thousand times eight comes first, giving forty thousand bits. Then five thousand bytes. Then five kilobytes, with every line wearing its unit.

Now the width itself, because bits per character is not always eight. Most questions state the bits per character, so use the number in front of you. Where one leaves it out, your board's figure for ASCII is in the table: seven bits on two boards, eight on the third. Take the same two thousand four hundred characters, this time at seven bits each. Times the bits: two thousand four hundred, times seven, is sixteen thousand eight hundred bits. Divide by eight: sixteen thousand eight hundred, divided by eight, is two thousand one hundred bytes, exactly. Seven bits per character does not make the sum awkward. It makes the file smaller, two thousand one hundred bytes instead of two thousand four hundred. Now add one more character, and watch what happens to the bytes. Two thousand four hundred and one characters at seven bits: how many bytes? Sixteen thousand eight hundred and seven bits. Divided by eight, that is two thousand one hundred point eight seven five bytes. A file is stored in whole bytes, so a part-used byte still takes a whole one. The file needs two thousand one hundred and one bytes. Keep the point eight seven five line in your working too, so it shows where the rounding came from. One character is one byte only when the code is eight bits wide. At seven bits, characters and bytes stop matching. One examiner's report, on a calculation involving ASCII text, says this: For the calculation many students incorrectly thought that ASCII is an eight-bit code. Those students used eight where the question needed seven, so every number after the first line came out too big. The habit: write the bits per character, and where it came from, on the very first line, before you multiply anything.

Next, a question about many files instead of one. A school keeps a hundred and fifty copies of a report. Each report is three thousand characters long, and each character takes one byte. The space is wanted in megabytes. The first two steps are done for one report. At one byte per character, times the bits and divide by eight cancel out, and one report is three thousand bytes. Two steps are left, and the first of them is what this question is testing. Pause and finish it: how many megabytes do all one hundred and fifty need? How many of them: three thousand bytes, times a hundred and fifty, is four hundred and fifty thousand bytes. And the unit step: divided by a million, that is nought point four five megabytes. One examiner's report, on a question about a set of ten images, records this: A common missed element was giving the file size of one image instead of multiplying it by ten to give the file size of the ten images. That was about images rather than text, and the missed step is the same. The answer stopped at one file. The fix is to underline the count in the question before you start, then ask how many of them before the unit step.

One more step to look at closely: the unit step, where the boards use different units. A kilobyte is a thousand bytes. A kibibyte is one thousand and twenty-four bytes. Use the unit the question names, and find your board's row in the table. Take ninety-six thousand bits, and give the size both ways. Divide by eight first. Ninety-six thousand bits is twelve thousand bytes. Now the unit step. Twelve thousand bytes, divided by a thousand, is twelve kilobytes. Divided by one thousand and twenty-four instead, it is eleven point seven kibibytes, to one decimal place. Twelve and eleven point seven describe one file, and the data in it has not changed. Why is the kilobyte number the larger of the two, for the same file? Because a kilobyte is smaller than a kibibyte, a thousand bytes against one thousand and twenty-four, so it takes more of them to make up the same file. One examiner's report puts the unit habit plainly: Candidates also struggled to remember that file storage size is in bytes. Those answers lost track of whether a number was bits or bytes. The fix is the one this video has used throughout: every line of working carries its unit, so a change of currency shows the moment it happens.

Now back to the hundred million text messages, with all four steps in hand. Times the bits: one hundred and sixty characters, times eight bits, is one thousand two hundred and eighty bits for one message. Divide by eight: one thousand two hundred and eighty bits is one hundred and sixty bytes per message. Two steps are left, and you have done both of them already today. Pause and finish the last two steps: how many gigabytes for a hundred million messages? How many of them: one hundred and sixty bytes, times a hundred million, is sixteen thousand million bytes. The unit step: a gigabyte is a thousand million bytes, so that is sixteen gigabytes. Sixteen gigabytes. A hundred million messages fit on a small memory stick, and the sum took four steps.

Four last checks. The first asks for the steps, and the rest are files this video never showed. What are the four steps, in order, from the start? Times the bits, divide by eight, how many of them, then the unit step. Now one thousand characters, at seven bits each. How many bytes? Seven thousand bits, divided by eight, is eight hundred and seventy-five bytes. Now forty files of eight hundred and seventy-five bytes. How many kilobytes? Forty lots of eight hundred and seventy-five is thirty-five thousand bytes, and that makes thirty-five kilobytes. One more: why did each text message come to one byte per character? Because every character was stored in eight bits, and eight bits make one byte. At seven bits, the messages would have been smaller.

You could teach this one if you can size a file you have never seen, from characters all the way to the right unit, without checking a thing. That is the moment for a thumbs up. If it has not settled, keep the video, and write the four steps out once by hand; written once, they tend to stay put. The limits of a fixed number of bits comes next, and asks what happens when the bits run out.

Next in the chapter: The limits of a fixed number of bits, and what happens when a value will not fit.

For more, visit scholafly.com, or watch the next video.

Related terms

For: AQA GCSE 8525, Edexcel GCSE 1CP2, OCR GCSE J277

On the specification

BoardSpecStatement
AQA GCSE 85253.3.3State that a bit is the fundamental unit of information and a byte is 8 bits, use the decimal prefixes kilo, mega, giga and tera, and compare quantities of bytes.
Edexcel GCSE 1CP22.3.1Data storage and compression
OCR GCSE J2771.2.3Units
For teachers

This GCSE Computer Science lesson teaches working out the size of a text file. By the end, students should be able to calculate the size of a text file from the bits per character and the number of characters, convert the answer into sensible units, and work out the storage capacity required for a set of files. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.