ScholaFly

CS02-06 Computer Science Watch

The limits of a fixed number of bits

Watch on YouTube

In this lesson

In this video you'll learn about the limits of a fixed number of bits for GCSE Computer Science.

By the end: Explain the limitations of representing data in binary when the number of available bits is fixed, and describe what happens when a value will not fit.

What it covers

  1. 1:16 The limits of a fixed number of bits: start with one bit
  2. 5:20 What happens when a value needs more than the frame can give
  3. 7:39 Back to the view counter

Key words

About this video

The limits of a fixed number of bits | GCSE Computer Science

Why a fixed number of bits limits the number of patterns, the labels you can give, and what overflow does when a value will not fit.
Edexcel 1CP2 GCSE. Units and file sizes 6 of 6.
Full Units and file sizes playlist: https://www.youtube.com/playlist?list=PLO0-7kcru9G8
More at https://scholafly.com

Watch first: Overflow in Binary Addition (8-Bit Overflow) - https://youtu.be/hDSxVYkfpzk
Video code: CS02-06 (search "ScholaFly CS02-06")

Videos in this chapter:
CS02-00 Units, characters and file size: Where to start: 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 the limits of a fixed number of bits. By the end, students should be able to explain the limitations of representing data in binary when the number of available bits is fixed, and describe what happens when a value will not fit. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.

Exam board specification references:
Pearson Edexcel Level 1/Level 2 GCSE (9-1) in Computer Science
- 2.2.4 Explain the limitations of binary representation when constrained by the number of available bits.

Read the transcript

In twenty fourteen, YouTube announced it had upgraded its view counter. One video was heading for two billion, one hundred and forty-seven million, four hundred and eighty-three thousand, six hundred and forty-seven views. That number is the largest a thirty-two bit signed integer can hold. An integer is a whole number, and signed means it can be negative too, so half the patterns go on negative numbers. Nobody had done anything wrong. Years earlier, somebody had decided how many bits a view count was worth, and the world walked up to the edge of that decision. Every field in every system has an edge like that one. What sets the edge, and what moving it costs, is what this video works out.

Units, characters and file size ends here, with video six of six. It leans on one idea from the binary chapter, so if overflow is hazy, the video called Overflow is where to go back to.

Start with one bit. A single bit has two patterns, nought and one, so it can tell exactly two things apart. This topic is listed on one exam board's specification, the one shown in the table. The other two do not list it, though it ties together ideas they do examine. Now fix a frame of boxes, one box per bit, that never changes size. It is the eight-slot container from the video Overflow, with any number of slots. Add a second bit, and there are four patterns. A third bit makes eight. A fourth makes sixteen. Each extra bit does not add to the count. It doubles it. So n bits give two to the power of n patterns, and not one more. Three students are asked how many different values ten bits can represent. One says ten, one says twenty, and one says one thousand and twenty-four. Which of the three is right, and what did the other two do? One thousand and twenty-four, two to the power of ten. Ten counts one value per bit, and twenty adds two per bit, when every bit doubles. For a whole number that is never negative, called unsigned, those patterns start at nought. So n bits store nought up to two to the n, minus one. The minus one is there because nought uses up a pattern. Eight bits make two hundred and fifty-six patterns, and the highest value they store is two hundred and fifty-five.

Those patterns do not have to be amounts. A fixed number of bits also limits how many different things can be given a label at all. Take an address bus, the wires a processor uses to say which memory location it wants. Each location's address is a number that labels it, like the number on a pigeonhole. With an eight-bit address bus, how many locations, and what is the highest address? Two hundred and fifty-six locations, addressed nought to two hundred and fifty-five. The highest is one less than the count, because nought names a location too. A two hundred and fifty-seventh location could be built into the hardware and still never be reached. No pattern is left to name it. The same limit governs a character set, from the video Character sets and ASCII. Picture one that gives each character only five bits. With five bits per character, what are two things that set could not include? Five bits make thirty-two codes. The twenty-six capitals take twenty-six of them, so there is no room for all the lower-case letters, and none for all ten digits. Thirty-two slots will not even hold the alphabet twice. The limit decides what a set can contain before anyone types a word.

Next, what happens when a value needs more than the frame can give. Picture a system that stores a person's age in a field seven bits wide. A field is one stored item, and its width is how many bits it is given. What is the oldest age a seven-bit field can hold? One hundred and twenty-seven. Seven bits make one hundred and twenty-eight patterns, and nought takes one of them. Now, is seven bits a sensible width for an age, and what would an eighth bit buy? Sensible, just. The oldest person on record lived to one hundred and twenty-two, so the limit covers everyone so far. An eighth bit lifts it to two hundred and fifty-five, at the price of one more bit per person stored. And when a sum lands past the edge, that is overflow, from the video called Overflow: the result needs more bits than the frame has. Two eight-bit unsigned values are added: two hundred, and ninety. Keep the width fixed at eight boxes while the two are added. What value do the eight bits hold after that addition, and why? Thirty-four. The true total is two hundred and ninety, which needs nine bits. The ninth falls outside the frame, and what stays is two hundred and ninety, minus two hundred and fifty-six. Overflow is one case of the same limit. The frame ran out of patterns, and the part that did not fit was lost.

Back to the view counter. Reaching the edge was not a bug in the program; it was the width somebody chose for the field. So when a question asks why a value could not be stored, name the cause: the field width, the number of bits available. More bits are not free, though. More bits per item, times a great many items, is a bigger file and more memory, the same sum as in Working out the size of a text file. Fewer bits save space and lose values you may one day want. More bits buy range and cost storage. That is a trade-off, a gain that comes with a cost, and naming both sides is the answer. Try one: a game keeps each score in sixteen bits instead of eight. One gain, one cost? Scores can now reach sixty-five thousand five hundred and thirty-five instead of two hundred and fifty-five. Each score takes twice the room, and there may be millions of them. Whenever a question mentions a limit, ask how many bits there are, and so how many different values. Whether something looks clear is a different question. One examiner's report, on a question about a picture stored with one bit for each dot, records that a lot of responses thought the question was about resolution and thought that the image was not clear because one-bit resolution was too low. Resolution is about how much detail a picture shows. Those answers talked about sharpness, when the point was that one bit can only have two values. The fix is to start from the bits every time: how many bits, so how many values, and what that leaves out. How an image is stored, in the next chapter, does the picture side of this properly. How sound is stored meets the same limit in sound. Put as one sentence: a bit you did not spend is a value you cannot have.

To close, some new numbers for the same rule, then one last look at the view counter. How many patterns do six bits make, and what is the highest unsigned value? Sixty-four patterns, so the highest value is sixty-three, because nought takes one. Next, a four-bit counter holds fifteen, and one is added. What does it hold? Nought. Sixteen needs five bits, so the fifth falls off and all four boxes read nought. That is overflow. Now, can a five-bit address bus reach forty different locations? No. Five bits make thirty-two patterns, so only thirty-two locations can ever be named. One more: what put that view counter near its edge in the first place? A width chosen years before: thirty-two bits for a view count. Nothing broke, and the fix was more bits, at the cost of more storage for every count.

That closes the chapter, from a single bit up to the limit of bits. Any video in it you could explain to a friend from memory is yours: give it a thumb, and you never sit through it twice. Leave the rest unmarked and save the playlist. The next chapter, on images, sound and compression, keeps spending bits on every item, so these ideas come back round there.

That completes our chapter on Units, characters and file size. Next chapter: Images, sound and compression.

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

Related terms

For: Edexcel GCSE 1CP2

On the specification

BoardSpecStatement
Edexcel GCSE 1CP22.2.4Explain the limitations of binary representation when constrained by the number of available bits.
For teachers

This GCSE Computer Science lesson teaches the limits of a fixed number of bits. By the end, students should be able to explain the limitations of representing data in binary when the number of available bits is fixed, and describe what happens when a value will not fit. It works through four worked examples and the mistakes examiners report, and suits Foundation and Higher tier students.