Skip to content
Cambridge IGCSE0478

Number systems

Computer Science 0478 Chapter Notes

What this chapter covers

Number systemsText, sound and imagesData storage and compression
ShareWhatsAppPost
Number systems notes

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Number systems notes as text: skim, search, and jump between subtopics.

~20 min read

1. Why computers use binary

Any form of data needs to be converted to binary before a computer can process it. Text, images and sound are all stored as binary.

Data is processed using logic gates and stored in registers. A logic gate can only be set as a binary number.

Worked example 11 mark

Data is converted to binary to be stored by a computer.

(c) Tick one box to show the correct statement about why data is converted to binary for storing in a computer.

Statement
ABinary uses numbers and characters to store all the data.
BBinary is one type of data that a computer can store.
CData is processed by logic gates that can only be set as binary numbers.
DOnly binary numbers can be input into a computer.
  1. 1

    C: data is processed by logic gates that can only be set as binary numbers [1]

2. Denary, binary and hexadecimal

Denary is a base 10 system. Binary is a base 2 system. Hexadecimal is a base 16 system. Hexadecimal uses the digits 0 to 9 and the letters A to F, where A to F stand for 10 to 15.

To convert binary to denary, add the place values of the 1s. In 8 bits the place values are 128, 64, 32, 16, 8, 4, 2, 1. To convert hexadecimal to denary, multiply each digit by its place value: 256, 16, 1.

To convert between binary and hexadecimal, work in groups of four bits (nibbles). Each nibble is one hexadecimal digit. Keep the leading zeros so an 8-bit answer has 8 bits.

10010110₂ = 128 + 16 + 4 + 2 = 150

0A2₁₆ = (10 × 16) + 2 = 162

1111 0000 1000₂ = F08₁₆

Examiner insight

“It would be helpful for candidates to understand that values 10 to 15 are represented with a character value of A to F.” “Some candidates did not include leading zeros.”

Worked example 12 marks

(a) Convert the denary number 150 into an 8-bit binary number.

(b) Convert the hexadecimal number F08 into a 12-bit binary number.

  1. 1

    (a) 150 = 128 + 16 + 4 + 2, so 10010110 [1]

  2. 2

    (b) F = 1111, 0 = 0000, 8 = 1000, so 1111 0000 1000 [1]

3. Why hexadecimal is used

Hexadecimal is a shorter representation of binary. One hexadecimal digit stands for four bits.

It is easier to read and understand than binary, and easier to debug. It uses less screen space than binary. It is used where people read binary values, for example error codes, MAC addresses and HTML colour codes.

The computer still stores the value as binary, so hexadecimal does not save storage space.

Examiner insight

“The most common incorrect answer was ‘uses less storage space’. It would be beneficial for candidates to understand that hexadecimal will be stored as a binary value, so no storage space will be saved.” “It would be beneficial for candidates to understand that the use of hexadecimal is for ease of understanding for the user, and that it does not make things any easier to understand for the computer.”

Worked example 13 marks

A video streaming service uses hexadecimal to display error codes when problems occur with their videos.

(a) Tick one box to show which statement is incorrect about why hexadecimal is used to display the error codes.

(b) There is a problem with streaming a video and the error codes 152 and 30F are displayed. Convert the two hexadecimal error codes to binary numbers.

Statement
AHexadecimal is easier to debug than binary.
BHexadecimal is easier to read than binary.
CHexadecimal uses less screen space than binary.
DHexadecimal uses less storage space than binary.
  1. 1

    (a) D [1]

  2. 2

    (b) 152 = 0001 0101 0010 [1]

  3. 3

    30F = 0011 0000 1111 [1]

4. Binary addition and overflow

Add binary numbers column by column from the right. 0+0=0, 1+0=1, 1+1=10 (write 0, carry 1) and 1+1+1=11 (write 1, carry 1). Write the carries down as working.

A register has a predefined limit. An 8-bit register holds values up to 255. An overflow error occurs when a value outside this limit should be returned. The carry out of the eighth bit is the overflow bit.

8-bit maximum = 2⁸ - 1 = 255

Examiner insight

“Some candidates converted the values to denary, added the values and converted the answer back to binary. Candidates should note that this is not answering the question, as they do not demonstrate binary addition.” “Many candidates were able to recognise that an overflow error occurs when the value is larger than 255.”

Worked example 14 marks

(f) Add the binary numbers 10011101 and 11110000 using binary addition. Give your answer in binary. Show all your working.

  1. 1

    ``` 1 1 1 1 0 0 1 1 1 0 1 + 1 1 1 1 0 0 0 0 1 1 0 0 0 1 1 0 1 ```

  2. 2

    right nibble 1101 correct [1]

  3. 3

    left nibble 1000 correct [1]

  4. 4

    three carries shown as working [1]

  5. 5

    overflow bit 1 shown. Answer 110001101 [1]

5. Logical binary shifts

In a logical shift every bit moves the same number of places. Bits shifted out of the end of the register are lost. Zeros are shifted in at the opposite end.

A left shift multiplies the number by 2 for each place. A right shift divides it by 2 for each place. In a left shift the most significant bit is lost. In a right shift the least significant bit is lost.

left shift by n places: × 2ⁿ

right shift by n places: ÷ 2ⁿ

Examiner insight

“The most common incorrect answer was from candidates who performed the binary shift to the right and not the left.” “Some candidates replaced the values lost with 1s instead of 0s.”

Worked example 11 mark

(c) Give the 8-bit binary value after a logical binary shift left of two places is performed on the binary number 00110101.

  1. 1

    Move every bit two places left, drop the two bits at the left and add 00 at the right: 11010100 [1]

6. Two’s complement

Two’s complement is a base 2 number system that represents positive and negative integers. In 8 bits the most significant bit has place value -128. The other place values are 64, 32, 16, 8, 4, 2, 1.

A value with a leading 0 is positive. Read it as ordinary binary and do not flip it. A value with a leading 1 is negative: add the place values, with -128 for the leading bit.

To store a negative number, write the positive value in 8 bits, flip every bit and add 1.

-14: 00001110, flip: 11110001, add 1: 11110010

Examiner insight

“Some candidates attempted to ‘flip’ the binary value and then converted this resulting value to denary.” “Some candidates gave the binary value for 22 instead of –22.”

Worked example 13 marks

The current temperature is stored as a two’s complement binary integer and is displayed as a denary number.

(d)(i) Give the denary number that would be displayed for each of the two’s complement binary integers 00100011 and 11101010.

(ii) Give the two’s complement binary integer that would be stored when the denary number 14 is displayed.

  1. 1

    00100011 = 32 + 2 + 1 = 35 [1]

  2. 2

    11101010 = -128 + 64 + 32 + 8 + 2 = -22 [1]

  3. 3

    14 is 0000 1110 [1]

Recap

  • Data is converted to binary because logic gates can only be set as binary numbers.
  • Denary is base 10, binary is base 2, hexadecimal is base 16.
  • Convert binary and hexadecimal in groups of four bits. Keep leading zeros.
  • Hexadecimal is easier for humans to read. It does not save storage space.
  • Overflow: a value above 255 in an 8-bit register.
  • Left shift multiplies by 2 each place. Right shift divides by 2 each place.
  • Two’s complement: leading 0 is positive, leading 1 is negative. The leading bit has value -128.

7. Text as binary

Text is converted to binary to be processed by a computer.

A character set contains all the characters that can be represented. Each character is given a binary value in the character set.

Examiner insight

“Some candidates focussed on how a keyboard process key presses, rather than how text is converted to binary.” “It would be beneficial for candidates to have a greater understanding of how text is converted to binary using a character set.”

Worked example 13 marks

A student opens a document on their computer and inputs text. Explain how the computer represents the text.

  1. 1

    A character set is used [1]

  2. 2

    It contains all the characters that can be represented [1]

  3. 3

    Each character is given a binary value [1]

8. ASCII and Unicode

ASCII and Unicode are both character sets.

Unicode allows a greater range of characters and symbols than ASCII, including different languages and emojis.

Unicode requires more bits per character than ASCII.

Examiner insight

“Most referred to Unicode having more characters. Some expanded on this to state it could cover more languages.” “Common errors included incorrectly stating the binary for the integer value of 9 rather than the binary value of the ASCII value for 9.”

Worked example 13 marks

The computer uses the ASCII character set for a text file. One word from the text file is ‘cat’. The ASCII denary value for the character ‘c’ is 99.

(i) Give the ASCII denary values for ‘a’ and ‘t’.

(ii) Identify one other character set that the computer could use.

  1. 1

    ‘a’ is 2 letters before ‘c’: 99 - 2 = 97 [1]

  2. 2

    ‘t’ is 17 letters after ‘c’: 99 + 17 = 116 [1]

  3. 3

    Unicode [1]

9. Sound: sample rate and resolution

A sound wave is sampled for sound to be converted to binary, which is processed by a computer. A sound sample is a single measure of the amplitude (height) of the sound wave.

The sample rate is the number of samples taken in a second. The sample resolution is the number of bits per sample.

The accuracy of the recording and the file size increase as the sample rate and resolution increase.

Examiner insight

“Some candidates tried to describe the sample resolution in relation to an image.” “Few candidates were able to give any indication about how the accuracy of the recording could be increased.”

Worked example 12 marks

The student stores a video on their computer. The video contains sound and images. Complete the table with the missing terms and descriptions about sound and images.

The two rows about sound:

termdescription
sound sample
the number of samples that are recorded each second
  1. 1

    sound sample: a single measure of the amplitude (height) of a sound wave [1]

  2. 2

    the missing term is the sample rate (sampling rate) [1]

10. Images as pixels

An image is a series of pixels that are converted to binary, which is processed by a computer.

Each pixel is one colour. Each pixel has a binary value for its colour.

Examiner insight

“Some responses describe a pixel as all of the colours in the image, or all of the squares that make up the image.”

Worked example 13 marks

A student has an application (app) on their smartphone that can be used to identify the name of a flower. The student opens the app and takes a photograph of a flower. The photograph is stored as an image. Explain how the image is converted to binary for processing by the smartphone.

  1. 1

    The image is broken down into pixels [1]

  2. 2

    Each pixel is a single colour [1]

  3. 3

    Each colour (pixel) has a binary value [1]

11. Resolution and colour depth

The resolution is the number of pixels in the image: the dimensions of the image.

The colour depth is the number of bits used to represent each colour.

The file size and quality of the image increase as the resolution and colour depth increase.

Examiner insight

“Some candidates did not provide enough information and just stated that it was related to the quality of the image.” “A common error was stating it was the number of pixels per bit, or the number of pixels in an image.”

Worked example 13 marks

The student stores a video on their computer. The video contains sound and images. Complete the table with the missing terms and descriptions about sound and images.

The three rows about images:

termdescription
the smallest unit of an image that is made up of one colour
the dimensions of an image
colour depth
  1. 1

    pixel [1]

  2. 2

    (image) resolution [1]

  3. 3

    colour depth: the number of bits used for each colour (pixel) in an image [1]

Recap

  • Text is converted to binary using a character set. Each character has a binary value.
  • ASCII and Unicode are character sets. Unicode has a greater range of characters and needs more bits per character.
  • Sample rate = samples per second. Sample resolution = bits per sample.
  • Higher sample rate or resolution: more accurate recording, bigger file.
  • An image is a series of pixels. Each pixel is one colour with a binary value.
  • Resolution = number of pixels. Colour depth = bits used for each colour.
  • Higher resolution or colour depth: better quality, bigger file.

12. Measuring data storage

A bit is one binary digit. There are 8 bits in a byte. A nibble is half a byte, so one byte holds two nibbles.

Above the byte, each unit is 1024 times the one before it: kibibyte (KiB), mebibyte (MiB), gibibyte (GiB), tebibyte (TiB), pebibyte (PiB) and exbibyte (EiB).

A binary prefix such as mebibyte uses 1024 in calculations. A denary prefix such as megabyte uses 1000.

1 byte = 8 bits

1 KiB = 1024 bytes

1 GiB = 1024 MiB

Examiner insight

“In this question binary prefixes were used, therefore candidates needed to use the value of 1024 in calculations.” “Many candidates were able state the correct number of nibbles in 1 byte. The most common incorrect answer given was 4.”

Worked example 11 mark

Data storage can be measured in different units. Calculate how many kibibytes (KiB) are equal to 3072 bytes.

  1. 1

    3072 ÷ 1024 = 3 KiB [1]

13. Terms in a file-size question

A pixel is the smallest unit of an image that is made up of one colour. The resolution of an image is its dimensions.

Colour depth is the number of bits used for each colour or pixel. A sound sample is a single measure of the amplitude of a sound wave, and the sample rate is the number of samples recorded each second.

Examiner insight

“A common error was stating it was the number of pixels per bit, or the number of pixels in an image.” “Some candidates did not provide enough information and just stated that it was related to the quality of the image.”

Worked example 15 marks

The student stores a video on their computer. The video contains sound and images. Complete the table with the missing terms and descriptions about sound and images.

termdescription
the smallest unit of an image that is made up of one colour
sound sample
the dimensions of an image
colour depth
the number of samples that are recorded each second
  1. 1

    term: pixel [1]

  2. 2

    a (single) measure of the amplitude of a sound wave [1]

  3. 3

    term: (image) resolution [1]

  4. 4

    the number of bits used for each colour or pixel [1]

  5. 5

    term: sample rate [1]

14. Calculating image and sound file sizes

Answers must be in the units the question asks for. Calculations use 1024, not 1000.

For an image, multiply the number of pixels by the colour depth. For a sound file, multiply the sample rate, the resolution and the length of the track in seconds. With the colour depth or resolution in bits, the answer is in bits.

Divide by 8 to change bits to bytes. A colour depth given in bytes gives bytes straight away. Then divide by 1024 once for each step up to the unit asked for.

image size (bits) = width × height × colour depth

sound size (bits) = sample rate × resolution × length (s)

bytes = bits ÷ 8

Examiner insight

“Some candidates divided by 1024 once instead of twice. Some candidates multiplied by 8 to calculate the bits for a colour depth of 1 byte instead of 2 bytes.” “The most common incorrect answers did not struggle with the mathematics of the calculation, but with the correct methodology for calculating the file size.”

Worked example 12 marks

An image file has a resolution of 1024 pixels high × 1024 pixels wide. The colour depth is two bytes. Calculate the file size of the image. Give the answer in MiB. Show your working.

  1. 1

    working: 1024 × 1024 × 2 bytes, then divide by 1024 × 1024 [1]

  2. 2

    file size of image = 2 MiB [1]

15. Why data is compressed

Compression exists to reduce the size of the file.

This means less storage space is needed, less bandwidth is required and the transmission time is shorter. A video is also less likely to buffer when it is streamed.

Examiner insight

“It would be helpful for candidates to understand that the downloading process would not change, it would be the download time that would be reduced.” “Some candidates lacked detail in their response such as it makes the size smaller, and it uses less space.”

Worked example 11 mark

The video streaming service compresses their videos using lossless compression. Give one advantage to the video streaming service of choosing lossy compression instead of lossless compression to compress the videos.

  1. 1

    smaller file size, so less storage space or a shorter transmission time [1]

16. Lossy compression

Lossy compression reduces the file size by permanently removing data. Examples are reducing the resolution or colour depth of an image, and reducing the sample rate or resolution of a sound.

The data removed is unnecessary data, such as colours that cannot be distinguished between. Once it is removed, the original cannot be recovered.

MP4 and JPEG are lossy.

Examiner insight

“Candidates need to make sure they are referring to the removal of unnecessary data and not unwanted data, because the compression algorithm will not understand what is wanted or not but can identify unnecessary data such as colours that cannot be distinguished between.” “Some candidates gave an example of compression rather than a type of compression.”

Worked example 12 marks

The video streaming service compresses their videos using lossless compression. Give two reasons why the video streaming service chose lossless compression instead of lossy compression.

  1. 1

    they want to retain the original version of the video, which can be recovered [1]

  2. 2

    the videos keep the highest quality, because quality is not reduced [1]

17. Lossless compression

Lossless compression reduces the file size without permanent loss of data. An example is run length encoding (RLE).

A compression algorithm finds repeated patterns and removes the redundancy. No data is removed, so nothing that a person could hear or see is thrown away.

Examiner insight

“Few candidates were able to describe how lossless would reduce the size of the video file. Most candidates described how lossy compression would do this.” “Many candidates described the benefits of lossless compression, rather than how data is compressed using the lossless method.”

Worked example 14 marks

The video streaming service compresses their videos using lossless compression. Explain how the videos are compressed using lossless compression.

  1. 1

    a compression algorithm is used, such as RLE [1]

  2. 2

    repeating frames or pixels are identified [1]

  3. 3

    ... and indexed [1]

  4. 4

    redundancy is eliminated by recording the differences between each frame [1]

Recap

  • 8 bits in a byte. A byte is two nibbles.
  • Each unit up (KiB, MiB, GiB, TiB, PiB, EiB) is 1024 times the one before.
  • Image size = width × height × colour depth. Sound size = sample rate × resolution × length in seconds.
  • Divide bits by 8 for bytes, then by 1024 for each step up. Give the unit asked for.
  • Compression reduces file size: less storage, less bandwidth, shorter transmission time.
  • Lossy permanently removes data. Lossless loses nothing, for example RLE.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. A student takes a photograph. State what must be done to the photograph before a computer can process it.1 mark
  2. Convert the denary number 45 into an 8-bit binary number.1 mark
  3. Convert the hexadecimal number 1C4 into denary.2 marks
  4. Convert the hexadecimal number 14 into an 8-bit binary number.2 marks
  5. Convert the binary number 101100001110 into hexadecimal.2 marks
  6. A programmer reads memory values displayed in hexadecimal. (a) Give two reasons why hexadecimal is used instead of binary. (b) The programmer says the values take less storage space in hexadecimal. Explain why this is wrong.3 marks
  7. Add the 8-bit binary integers 01101011 and 00111001 using binary addition. Show the carries.3 marks
  8. Two 8-bit binary integers 11001000 and 01100100 are added in an 8-bit register. Explain what happens.4 marks
  9. A game stores a player’s score as a positive 8-bit binary integer in a register. The score is 01011100. (a) A bonus performs a logical left shift of two places on the register. Give the binary value now in the register and its denary value. (b) Explain why the bonus has not multiplied the score by 4. (c) A penalty then performs a logical right shift of three places on your answer to (a). Give the value now in the register as two hexadecimal digits.6 marks
  10. A weather buoy stores each temperature as an 8-bit two’s complement integer. It transmits each stored value as two hexadecimal digits. (a) The buoy transmits 5D and then D5. Give the denary temperature for each value. (b) The temperature falls to -37 °C. Give the two hexadecimal digits transmitted. (c) A student reads D5 as 213. Explain the mistake.6 marks
  11. A student types the word ‘hello’. Describe how the computer stores each letter.2 marks
  12. Give two differences between ASCII and Unicode.2 marks
  13. State what is meant by sample rate and by sample resolution.2 marks
  14. Define the terms pixel and image resolution.2 marks
  15. In ASCII the digit characters ‘0’ to ‘9’ are in order and the character ‘0’ has denary value 48. Give the ASCII denary value of the character ‘7’.2 marks
  16. A sound recording is saved again with a lower sample rate. State the effect on the accuracy of the recording and on the file size.2 marks
  17. The colour depth of an image is changed from 8 bits to 32 bits. (a) State what a colour depth of 32 bits means. (b) State the effect on the file size and the quality of the image.3 marks
  18. An image has a colour depth of 3 bits. Calculate the maximum number of different colours it can represent.2 marks
  19. A camera in a nest box stores each image as 40 pixels wide and 30 pixels high. Each pixel can be any one of 16 different colours. (a) Give the smallest colour depth that allows 16 different colours. (b) Calculate the number of bits needed to store one image. (c) To save storage space, the width and the height of the image are both halved and the colour depth is reduced to 2 bits. Calculate how many of the new images can be stored in the bits used by one original image. (d) Give the maximum number of different colours in a new image.7 marks
  20. A birdsong recorder has two settings. Setting X: 8000 samples per second, 8 bits per sample. Setting Y: 4000 samples per second, 16 bits per sample. The same 3-second call is recorded once with each setting. (a) Calculate the number of bits used by each recording. (b) Using the terms sample rate and sample resolution, describe two ways in which the recordings differ. (c) Setting Z is 8000 samples per second with 16 bits per sample. State how the accuracy of the recording with setting Z compares with setting X. Calculate how many seconds of sound setting Z stores in the bits that setting X used for the call.8 marks
  21. State how many bits are in one byte.1 mark
  22. State how many nibbles are in one byte.1 mark
  23. Put these units in order, smallest first: gibibyte, exbibyte, kibibyte, tebibyte, pebibyte, mebibyte.2 marks
  24. Calculate how many mebibytes (MiB) are in 5 GiB.2 marks
  25. Calculate how many kibibytes (KiB) are equal to 163 840 bits.2 marks
  26. A school emails a photograph to parents after compressing it. State the purpose of compressing the photograph and one effect on the email.2 marks
  27. A music company compresses its master recordings before storing them. State which type of compression it should use and give one reason.2 marks
  28. An image is 256 pixels wide and 128 pixels high. The colour depth is 16 bits. Calculate the file size in KiB.3 marks
  29. A language app records a learner speaking. The recording has a sample rate of 32 768 samples per second and a resolution of 16 bits. It is 4 minutes 16 seconds long. (a) Calculate the file size of the recording in MiB. (b) To save storage space, the app uses lossy compression. It halves the sample rate and reduces the resolution to 8 bits. Calculate the file size of the compressed recording in KiB. (c) State why the app cannot get the original recording back from the compressed file.6 marks
  30. A weather station takes one photograph of the sky every 30 minutes. Each photograph is 4096 pixels wide and 2048 pixels high. The colour depth is 3 bytes. The photographs are not compressed. (a) Calculate the file size of one photograph in MiB. (b) The photographs are stored on a memory card that holds 3 GiB. Calculate how many photographs the card can hold. (c) Calculate the number of complete days of photographs the card can hold.6 marks

Go deeper

Practise and revise with member-only material for this chapter.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters