Skip to content

1.2.4 Data storage

GCSE · Paper 1 · Computer systems · Section 1.2 · 20 flashcards · 12 practice questions

Questions

1.2.4 Data storage

A computer is made of circuits that are either on or off. So it can only store two states. We write these states as 1 (on) and 0 (off). Every number, letter, picture and sound on a computer is stored as a pattern of 1s and 0s.

Definition
A bit is a single binary digit: 0 or 1. Eight bits make a byte.

Numbers

Binary

Denary is the number system you use every day. It has ten digits (0 to 9), and each place is worth 10 times more than the one to its right. Binary has two digits (0 and 1), and each place is worth 2 times more than the one to its right.

In the exam you only work with positive whole numbers up to 8 bits. That means the values 0 to 255.

Key Point
Place values for 8 bits
1286432168421
The left-hand bit is the most significant bit (MSB). It has the biggest value (128). The right-hand bit is the least significant bit (LSB). It has the smallest value (1).

Binary to denary

Write the place values above the bits. Add up the place values that have a 1 under them.

Worked Example
Convert 10110101 to denary.
1286432168421
10110101
128 + 32 + 16 + 4 + 1 = 181

Answer: 181

Denary to binary

Work from the left. If the place value fits into what is left, write 1 and subtract it. If it does not fit, write 0.

Worked Example
Convert 157 to binary.

- 128 fits into 157. Write 1. 157 - 128 = 29.
- 64 does not fit into 29. Write 0.
- 32 does not fit into 29. Write 0.
- 16 fits into 29. Write 1. 29 - 16 = 13.
- 8 fits into 13. Write 1. 13 - 8 = 5.
- 4 fits into 5. Write 1. 5 - 4 = 1.
- 2 does not fit into 1. Write 0.
- 1 fits into 1. Write 1. 1 - 1 = 0.

Answer: 10011101

Check: 128 + 16 + 8 + 4 + 1 = 157.

Adding two binary numbers

Add column by column from the right, as you do in denary. There are only four facts to know:

SumWriteCarry
0 + 00none
0 + 11none
1 + 101
1 + 1 + 1 (with a carry)11
Worked Example
Add 00110101 and 01001110.

Working from the right:

- Bit 0: 1 + 0 = 1
- Bit 1: 0 + 1 = 1
- Bit 2: 1 + 1 = 0, carry 1
- Bit 3: 0 + 1 + carry 1 = 0, carry 1
- Bit 4: 1 + 0 + carry 1 = 0, carry 1
- Bit 5: 1 + 0 + carry 1 = 0, carry 1
- Bit 6: 0 + 1 + carry 1 = 0, carry 1
- Bit 7: 0 + 0 + carry 1 = 1

Answer: 10000011

Check in denary: 53 + 78 = 131, and 10000011 = 128 + 2 + 1 = 131.

Overflow

Definition
Overflow happens when the result of a calculation is too big to fit in the number of bits available. With 8 bits the biggest number is 255, so any answer above 255 overflows.

You can see overflow in a binary addition. There is a carry out of the left-hand (most significant) column, and there is no 9th bit to put it in.

Worked Example
Add 11010110 and 01110011 in an 8-bit register.

- Bit 0: 0 + 1 = 1
- Bit 1: 1 + 1 = 0, carry 1
- Bit 2: 1 + 0 + carry 1 = 0, carry 1
- Bit 3: 0 + 0 + carry 1 = 1
- Bit 4: 1 + 1 = 0, carry 1
- Bit 5: 0 + 1 + carry 1 = 0, carry 1
- Bit 6: 1 + 1 + carry 1 = 1, carry 1
- Bit 7: 1 + 0 + carry 1 = 0, carry 1

The last carry has nowhere to go. The 8-bit answer is 01001001 (73), which is wrong.

Check in denary: 214 + 115 = 329. That is more than 255, so the answer overflows. The true answer is 256 + 73 = 329.

Binary shifts

A binary shift moves every bit to the left or right by a number of places. Gaps are filled with 0s. Bits that move past either end are lost.

  • •
    A left shift moves bits to the left. Each place shifted multiplies the number by 2.
  • •
    A right shift moves bits to the right. Each place shifted divides the number by 2 (the remainder is lost).
Worked Example
Shift 00010110 left by 2 places.

Move every bit two places left, drop the two bits that fall off the left end, and add 00 on the right.

00010110 becomes 01011000

Effect: 22 became 88. It was multiplied by 2 twice, so 22 x 4 = 88.
Worked Example
Shift 10110100 right by 3 places.

Drop the three bits on the right (100). Add 000 on the left.

10110100 becomes 00010110

Effect: 180 became 22. It was divided by 2 three times, so 180 / 8 = 22.5, and the 0.5 is lost.
Warning
If a 1 is shifted off the end, the result is wrong. For example, 10110100 (180) shifted left by 1 gives 01101000 (104), not 360. The 1 that fell off the left end has been lost.

Hexadecimal

Hexadecimal (hex) is base 16. It has 16 digits: 0 to 9, then A to F.
Denary101112131415
HexABCDEF

In this course hex numbers have two digits (00 to FF). The left digit is worth 16 and the right digit is worth 1.

Hex is used because it is shorter than binary, so it is easier for people to read, write and remember, and there are fewer mistakes. For example, 10110101 is B5. Colour codes and memory addresses are often shown in hex.

Key Point
Each hex digit stands for exactly 4 bits (a nibble). So one byte is two hex digits.
Binary00000001001000110100010101100111
Hex01234567
Binary10001001101010111100110111101111
Hex89ABCDEF
Worked Example
Denary to hex: convert 173 to hex.

- 173 / 16 = 10 remainder 13.
- 10 is A. 13 is D.

Answer: AD

Check: 10 x 16 = 160, and 160 + 13 = 173.
Worked Example
Hex to denary: convert 3F to denary.

- 3 x 16 = 48.
- F is 15.
- 48 + 15 = 63
Worked Example
Binary to hex: convert 10110101 to hex.

Split into two groups of 4 bits: 1011 and 0101.

- 1011 = 11 = B
- 0101 = 5

Answer: B5
Worked Example
Hex to binary: convert 7C to binary.

- 7 = 0111
- C (12) = 1100

Join them: 01111100

Check: 64 + 32 + 16 + 8 + 4 = 124, and 7 x 16 + 12 = 124.

Characters

A computer stores each character (letter, digit, symbol) as a binary number. A character set is the list of all the characters a computer can use, and the binary code given to each one.

ASCII

ASCII is a character set. In the exam, treat ASCII as using 8 bits for each character. With 8 bits you can make 2^8 = 256 different codes, so ASCII can represent 256 characters. That is enough for English letters (capital and lower case), digits, punctuation and some control codes.

You do not need to memorise the codes. The question will give you one code, and you work out the others.

Key Point
Character codes are in order. The code for 'B' is one more than the code for 'A'. The code for 'C' is one more again, and so on. The digits and the lower case letters are also in order.
Worked Example
In ASCII, the code for 'D' is 68. What is the code for 'G'?

D, E, F, G: 'G' is 3 letters after 'D'.

68 + 3 = 71

The order of the codes means a computer can sort words into alphabetical order by comparing numbers.

Unicode

256 characters is not enough for every language, and not enough for symbols and emoji. Unicode is a much larger character set. It uses more bits per character (16 bits or more) so it can represent over a hundred thousand characters, from many languages and writing systems.

Pros & Cons
Advantages of UnicodeDisadvantages of Unicode
Far more characters, including other languages and emojiMore bits per character, so text files are bigger
Key Point
The more bits used for each character, the more different characters can be stored. The cost is that each character takes up more storage space.

Images

A bitmap image is a grid of tiny squares called pixels (picture elements). Each pixel has one colour. The computer stores a binary colour code for each pixel, and the pixels are stored in order, row by row.

Colour depth

Definition
Colour depth is the number of bits used to store the colour of each pixel.
Colour depthNumber of colours
1 bit2 (for example black and white)
2 bits4
8 bits256
24 bitsover 16 million

Each extra bit doubles the number of colours. A bigger colour depth gives more accurate colours and better quality, but each pixel needs more bits, so the file is bigger.

Resolution

Definition
Resolution is how many pixels make up the image, usually written as width x height. For example, 1,920 x 1,080.

A higher resolution has more pixels, so the image has more detail and looks sharper. But there are more pixels to store, so the file is bigger. A low resolution image looks blocky (pixelated) when it is enlarged.

Metadata

Definition
Metadata is data about the file, stored with it. It is not part of the picture itself.

An image file needs metadata so that the computer can rebuild the picture. Examples are the width, the height and the colour depth. Cameras also add the date, the time and the file type.

Exam Tip
For quality and file size, give a pair: "Increasing the colour depth means more colours can be shown, so quality improves, but each pixel needs more bits, so the file size increases." The same pattern works for resolution.

Sound

Real sound is analogue. It is a smooth, continuous wave. A computer can only store digital data, so the sound must be turned into numbers. This is done by sampling.

  • 1.
    The sound wave is measured at regular, equal intervals of time. Each measurement is a sample.
  • 2.
    The height (amplitude) of the wave at that moment is rounded to the nearest value the computer can store.
  • 3.
    Each value is stored as a binary number.
To play the sound, the stored values are read in order and used to rebuild the wave.

Sample rate

Definition
Sample rate is the number of samples taken every second. It is measured in hertz (Hz). For example, 44,100 Hz means 44,100 samples each second.

A higher sample rate gives a closer copy of the original wave, so the sound is better quality. There are more samples to store, so the file is bigger.

Bit depth

Definition
Bit depth is the number of bits used to store each sample.

A higher bit depth means each sample can be stored more precisely, so the sound is better quality. Each sample uses more bits, so the file is bigger.

Duration

Duration is how long the recording lasts. A longer recording has more samples, so the file is bigger. Duration does not change the quality.
Pros & Cons
Increase thisBenefitCost
Colour depthMore colours, better qualityBigger file
ResolutionMore detail, sharper imageBigger file
Sample rateCloser to the original soundBigger file
Bit depthMore precise samplesBigger file
Remember
How to calculate a file size from these values is covered in topic 1.2.3 (units). Here you only need to know the effect on quality and size.

Exam technique

  • •
    State and give: a short fact, one mark each. For example, "State what a pixel is."
  • •
    Convert and calculate: show your working. Marks are given for the method, so write the place values, the carries or the shifted bits. State the final answer clearly and keep all 8 bits.
  • •
    Describe: say what happens, in order. For sampling, give the steps.
  • •
    Explain: give a reason as well as a fact. "The file is bigger because each pixel needs more bits."
  • •
    Compare: talk about both things. For example, ASCII and Unicode.
  • •
    Link every change to its effect on both quality and file size.
  • •
    For overflow, say that the result is more than 255 and so does not fit in 8 bits.