Computer Science 2210 ยท Chapter 1 of 12
Data Representation
5 revision notes on Data Representation for Cambridge O Level Computer Science (2210). 84 past-paper questions on this chapter to practise.
About this chapter
- Syllabus
- 1
- Section
- Paper 1 ยท Computer systems
- On Paper 1
- In every paper, usually Questions 1-3: 6 to 22 marks
- Number part
- Conversions, binary addition and overflow, logical shifts, two's complement
- Media part
- Character sets, sound sampling, image resolution and colour depth
- Storage part
- Units (bit to EiB), image and sound file sizes, lossy and lossless compression
- Reading time
- 5 notes ยท about 76 min
- Past-paper questions
- 84 to practise
Study these notes in order
5 notes cover this chapter. Work through them 1 โ 5: each one ends with a quiz, so you know you're ready for the next.
Start here ยท Note 1 of 5 ยท 19 min read
Number systems: binary, denary and hexadecimal
- Number Systems
- Number Systems
- Number Systems
- Text, Sound and Images
- Data Storage and Compression
Download and print
A4 PDFs of the 5 notes above, ready to print or use offline.
Formula bank
Every formula and rule in this chapter. All Computer Science formulas on one page โ
Data storage units, file sizes and compression
Image file size (bits)Learn itwidth ร height ร colour depthresolution in pixels, colour depth in bitsUse it when an image with a resolution and a colour depth
Sound file size (bits)Learn itsample rate ร sample resolution ร length in secondsrate in Hz (samples per second), resolution in bitsUse it when a recording with a rate, resolution and length
Bits โ bytes โ KiB โ MiBLearn itรท 8, then รท 1024, then รท 1024Use it when an answer asked in KiB or MiB
Summary notes
The key points of every note, for a last read before a test.
Number systems: binary, denary and hexadecimal
- Computers use binary because they are made of switches / logic gates with only two states (1 and 0). All data is converted to binary.
- Denary is base 10, binary is base 2 (0, 1), hexadecimal is base 16 (0-9, A-F).
- 8-bit place values: 128 64 32 16 8 4 2 1. Binary to denary: add the place values of the 1s.
- Denary to binary: subtract the biggest place value that fits (or divide by 2, read remainders upwards). Give the number of bits asked for.
- One hex digit = 4 bits. Binary โ hex: group in fours from the right.
- Hex to denary: digit ร 16 + digit (ร 256 for a third digit). Denary to hex: go through binary, or divide by 16.
- n bits hold 0 to 2โฟ โ 1 (8 bits: 0-255). Fewest bits: first power of 2 bigger than the number; hex: digits ร 4.
Hexadecimal uses, binary addition and overflow
- Hex is for humans: a shorter representation of binary, easier to read, write, remember and debug, fewer mistakes, less screen space. It converts easily because one hex digit = 4 bits.
- Uses of hex: HTML colour codes, MAC addresses, IPv6 addresses, memory addresses / dumps, error codes, assembly language, URLs, character codes.
- Binary addition: 1 + 1 = 0 carry 1; 1 + 1 + 1 = 1 carry 1. Work right to left and show every carry.
- Overflow: the result is too large for the number of bits in the register (over 255 for 8 bits), so an extra bit would be needed and the stored value is wrong.
Logical shifts and two's complement
- Logical shift: every bit moves left or right; bits that fall off are lost; 0s fill the empty places.
- Left shift n places = ร 2โฟ; right shift n places = รท 2โฟ. If 1s are lost, the result is inaccurate / wrong.
- Two's complement: the MSB is worth โ128. MSB 1 = negative. Range โ128 to +127.
- Negative denary โ two's complement: write the positive in binary, flip every bit, add 1.
- Two's complement โ denary: โ128 + the other place values (when the MSB is 1).
Text, sound and images
- Text: a character set gives every character a unique binary code; the codes are stored in sequence.
- ASCII: 7 (or 8) bits, 128 (256) characters, English. Unicode: up to 16/32 bits, many languages and emojis, more storage per character.
- Sound: microphone โ wave sampled โ amplitude measured โ each sample given a binary value.
- Sample rate = samples per second; sample resolution = bits per sample. Higher โ more accurate, bigger file.
- Image: grid of pixels, each colour a binary code. Resolution = number of pixels; colour depth = bits per colour. Higher โ better quality, bigger file.
Data storage units, file sizes and compression
- bit โ nibble (4 bits) โ byte (8 bits) โ KiB โ MiB โ GiB โ TiB โ PiB โ EiB, ร 1024 each step from byte up.
- Image size (bits) = width ร height ร colour depth. Sound size (bits) = sample rate ร resolution ร seconds.
- Bits รท 8 = bytes; รท 1024 = KiB; รท 1024 = MiB. Answer in the unit asked, show every stage.
- Compression reduces file size: less storage, quicker transmission, less bandwidth, fits email limits.
- Lossy permanently removes data (smaller, lower quality). Lossless removes nothing permanently (original restored).
- RLE (lossless): runs of repeated characters / pixels stored once with the number of repeats.
What the syllabus says you need to know
- Understand how and why computers use binary to represent all forms of data
- Understand the denary, binary and hexadecimal number systems and convert between them
- Understand how and why hexadecimal is used as a beneficial method of data representation
- Add two positive 8-bit binary integers and understand the concept of overflow
- Perform a logical binary shift on a positive 8-bit binary integer and understand its effect
- Use the two's complement number system to represent positive and negative 8-bit binary integers
- Understand how and why a computer represents text and the use of character sets (ASCII and Unicode)
- Understand how and why a computer represents sound, including the effects of the sample rate and sample resolution
- Understand how and why a computer represents an image, including the effects of the resolution and colour depth
- Understand how data storage is measured
- Calculate the file size of an image file and a sound file, using information given
- Understand the purpose of and need for data compression
- Understand how files are compressed using lossy and lossless compression methods
Can I do this? Chapter checklist
Number systems: binary, denary and hexadecimal
- I can explain why computers use binary (switches / logic gates, two states).
- I know the base and the digits of denary, binary and hexadecimal.
- I can convert binary to denary and denary to 8-bit binary.
- I can convert between binary and hex by grouping in fours, keeping every 0000.
- I can convert between hex and denary both ways.
- I can give the largest value of a register and the fewest bits for a number.
Hexadecimal uses, binary addition and overflow
Logical shifts and two's complement
Text, sound and images
- I can describe how text is converted to binary using a character set.
- I can compare ASCII and Unicode in four points.
- I can explain how sound is sampled and define sample rate and resolution.
- I can define pixel, resolution, colour depth and metadata.
- I can give the effects of changing resolution, colour depth, sample rate and resolution.
Data storage units, file sizes and compression
Ticks are saved on this device and match the checklist at the end of each note. Anything unticked: open it and revise that section.