Download presentation
Presentation is loading. Please wait.
1
Higher Computing Science Storing Information
Welcome to the first homework session for Higher Computing Science
2
This homework session will look at how different types of data require computers to use different methods of storage and will also look at a selection of questions on the topic from past papers
3
Learning content Storing Numbers: Integers (Binary, Hexadecimal
Real Numbers (Two's complement) Storing Text: ASCII Unicode Storing Graphics: Bitmapped Vector Graphics Compression (lossy, lossless) Storing Sound: compression Storing video: Past Paper Questions from 2017, 2016 and 2015
4
Storing Numbers
5
An integer is a number without a decimal fraction.
Storing Integers An integer is a number without a decimal fraction. An integer can be positive or negative. This is a common data type in procedural programming languages. The limits on integer storage believe it or not caused accountants some grief particularly when dealing with large sums of money or currencies suffering from high inflation (they understandably don’t like the uncertainty of real numbers) Examples:
6
Human (Decimal) system
104 103 102 101 100 Ten Thousands Thousands Hundreds Tens Units 1 3 5 6 1 × × × × 1 = 1356
7
Binary system 27 26 25 24 23 22 21 20 128s 64s 32s 16s 8s 4s 2s Units 1 = 35
8
Binary system 27 26 25 24 23 22 21 20 128s 64s 32s 16s 8s 4s 2s Units 1 = 255 (28 = 256)
9
The hexadecimal system uses base 16 instead of base 10 or base 2.
Because hexadecimal uses 16 digits instead of 10, we use the letters A to F to represent the decimal values 10 to 15. Converting binary numbers to hexadecimal makes them easier to read. 162 161 160 256s 16s Units 1 3 = 19 base 10 (16 + 3) = base 2 The hexadecimal system is used by computer scientists to make reading and writing binary numbers easier. An 8 digit binary number can be written as a two digit hexadecimal number. You will have come across hexadecimal notation in the colour codes for HTML in web pages, and if you have been unfortunate enough to encounter a blue screen of death on a Windows machine which gives the address of where the fatal error occurred in Hex notation. 162 161 160 256s 16s Units 2 F = 47 base 10 ( ) = base 2
10
Converting Decimal to Binary
Method 1: Find the largest power of two which is less than the number to convert. Subtract it and repeat with the remainder.
11
Convert 113 to binary 26 = 64 113-64 = 49 25=32 49-32 = 17 24=16
Converting Decimal to Binary Convert 113 to binary 26 = 64 = 49 25=32 49-32 = 17 24=16 17-16 =1 128 64 32 16 8 4 2 U 1 1 1 1
12
Converting Decimal to Binary
Method 2 Keep dividing by 2 and writing down the remainder until you are left with 0. Read the answer from the bottom up.
13
Converting Decimal to Binary
Convert 113 to binary = 2 113 R 56 1 28 14 7 3
14
Preparation question 1 State the minimum number of bits needed to represent the range of positive whole numbers from 0 to to = 16,777,216 numbers 210 = = 1,048, = 16,777,216 So 24 bits needed You will need a calculator in the exam.
15
Preparation question 2 State the largest whole number that can be stored as a 10-bit positive integer. 29 = bits needed 210 = bits needed So largest number is 1023 2^10 2^9 2^8 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0 1024 512 256 128 64 32 16 8 4 2 1
16
State the number of bits required to store 16777216 colours.
Preparation question 3 State the number of bits required to store colours. 224 = 16,777,216 24 bits (colours numbered 0 to )
17
Negative Integers
18
Two’s Complement (8 bits)
The most significant bit is negative 27 26 25 24 23 22 21 20 -128s 64s 32s 16s 8s 4s 2s Units 1 = 3
19
Two’s Complement (8 bits)
27 26 25 24 23 22 21 20 -128s 64s 32s 16s 8s 4s 2s Units 1 = -125
20
Two’s Complement (8 bits)
27 26 25 24 23 22 21 20 -128s 64s 32s 16s 8s 4s 2s Units 1 = -118
21
Converting negative numbers to Two’s Complement
Establish the bit length required Convert positive number to binary Complement the binary number Add 1
22
Convert -3 to 8 bit two's complement
+3 = Complement Add Result ( )
23
Convert -35 to 8 bit two's complement
+35 = Complement Add Result ( )
24
Range in two's complement notation
The number of bits an operating system allocates to storing integers determines the range of integers which can be stored. The range of numbers which can be stored in two's complement using 8 bits is: 127 to For n bits the range would be: 2n-1-1 to - 2n-1 Remember 2^7 is ie 2^ 8 -1
25
Preparation question 4 Early versions of Turbo Pascal ran on 16 bit machines and had a built in constant called MaxInt. Its value was What does this tell you about the system it used to store integers? Turbo Pascal used two's complement on 16 bit machines so integer storage could only store a total of integers. (2^16 = 65536) 16 bits gave a range of to It also had a LongInt constant which had a value of (32 bit two's complement).
26
Real Numbers
27
A real number is a number with a decimal
Real Numbers A real number is a number with a decimal point. They can be positive or negative.
28
Binary point 23 22 21 20 . 2-1 2-2 2-3 8s 4s 2s Units 1/2s 1/4s 1/8ths 1 The binary system uses a point (bicimil) just like the decimal system 1.011 =
29
Real numbers are stored using Floating Point notation.
A Floating Point number takes up more memory than a two’s complement number and may be less accurate.
30
Scientific Notation You will be familiar with how numbers like this are stored in the decimal system: 1.34 × 103 Exponent Mantissa = 1340
31
The exponent can be a positive or negative integer
Scientific Notation The exponent can be a positive or negative integer The mantissa is a real value between 1 and 10 1.34 × 10-3 Exponent Scientific notation allows us to represent very large or very small numbers using a short-hand where the number is represented by a value multiplied by a power of 10. Scientific notation consists of two parts, the mantissa – a decimal number between 1 and 10 and the exponent – an integer representing a power of ten. When very large or very small numbers are being represented then this system stores them with a limited degree of accuracy. This is an acceptable compromise because very large or very small measurements will not always be accurate to the same number of significant figures as would be needed to represent them as normal base 10 values. Mantissa = When very large or very small numbers are being represented then this system stores them with a limited degree of accuracy.
32
Floating Point Notation
Floating point notation uses a similar system to decimal scientific notation. Sign Bit Mantissa Exponent The sign bit is used to store whether it is positive or negative The exponent is a power of two just as the exponent in scientific notation was a power of 10 The mantissa is a bicimal value less than 1 (bicimal point at the left hand side) The Exponent is a power of two stored in a similar way to Two’s Complement notation because it can be positive or negative.
33
Floating Point Notation
Positive real numbers Sign Bit Mantissa Exponent = + 23 × .1101 = 110.1 = 6.5
34
Floating Point Notation
Negative real numbers Sign Bit Mantissa Exponent = × .1001 = =
35
Number Range in Floating Point notation
The exponent is an integer stored in a similar way to two's complement. 8 bits allocated to the exponent means it can represent a range of numbers between 2127 and 2-128
36
Number Range in Floating Point notation
Sign Bit Mantissa Exponent The number of bits allocated to the Exponent determines the range of numbers you can store. The number of bits allocated to the Mantissa determines the accuracy of the numbers you can store.
37
Floating Point Notation
Operating systems will allocate a specific number of bits to storing real values. Floating Point Notation will always be a compromise between how accurately you can store a number and how wide a range of numbers you wish to store.
38
Storing Text
39
Codes 0000000 to 0011111 ( 0 to 31) are control characters.
ASCII Code A common standard is necessary to make communication between computers and between applications possible. Originally ASCII was a 7 bit code providing 128 (27) possible characters. Codes to ( 0 to 31) are control characters. ASCII has its history in teletype machines. Control codes were used to send instructions to the recipient machine to take a new line, delete a character insert a tab etc.
40
An 8th bit was added to provide error detection.
Parity An 8th bit was added to provide error detection. The parity bit is a 1 or a 0 to make the total number of 1s in the code always an odd number. When the ASCII code is checked, an even number of 1s means that the character must have been corrupted in transit and needs to be re-transmitted. Note this will only detect 1 error per code. 2 errors will mean that the no of 1s is an odd number and it will be assumed to be correct. This is not error correction
41
Able to cope with non English characters.
Unicode Able to cope with non English characters. Uses 16 bits giving 216 (65536) possible characters. Is backwards compatible with ASCII. Uses more memory for each character than ASCII. Different versions of Unicode exist, including one which uses 32bits
42
Storing Graphics
43
Bitmapped Graphics Bitmaps are a grid of bits to store the information about the colour of each pixel in an image. The bit-depth of an image refers to the number of bits used to store the colour of each pixel.
44
Bit-depth and resolution
Bit depth = number of bits allocated to each pixel 1 bit = 2 colours 2 bits = 4 colours 3 bits = 8 colours 4 bits = 16 colours 24 bits = 16 million colours ( ) Resolution = total number of pixels in the image So long as bit depth and resolution remain constant, image sixe also does irrespective of content.
45
Graphics file size example
File size = resolution × bit-depth Example Resolution: 2 × 3 inches at 600 dots per inch (DPI) 600 × 600 × 2 × 3 = pixels Bit-depth: 256 colours = 8 bits × 8 = bits = 2109 KB = 2.05 MB I'm afraid we are stuck with the US measurement system here.
46
RGB Colour RGB colour uses 24 bits to represent the colour of each pixel. 8 bits for red, 8 bits for green and 8 bits for blue. Hex notation is used to make reading the binary values easier. Red Green Blue Colour Binary value 00 black FF white green 80 half green
47
Compression Bitmapped graphics compression is used to reduce storage space and transmission time. Lossless compression: identify repeated patterns which only need to be stored once along with how many times they occur. Lossy compression: identify areas where averaging the colour detail will cause least change to the image. Cameras can be set to use RAW format – but no common standard Losssless: GIF, PNG Lossy: JPEG
48
Are resolution independent.
Vector Graphics Stores images as a description of the shapes which make them up so that they can used to recreate that image rather than storing them as individual pixels. Are resolution independent. Take up less space than bitmapped graphics but re-drawing is more processor intensive. Changing complexity of image changes file size. Quality of reproduction depends on quality of the output device
49
Storing Sound
50
Bit-depth and Sample Rate
Bit depth = number of bits per sample Sample Rate = number of samples per second Both bit-depth and sample rate determine the quality (and the size) of the sound file. Common uncompressed formats WAV AIFF
51
Uses similar techniques to graphics compression:
Audio Compression Uses similar techniques to graphics compression: Lossless compression: identify repeated patterns which only need to be stored once along with how many times they occur. Lossy compression: identify audio information which can be removed causing the least change to the sound. Lossy: MP3, compression – identify sounds which appear in both channels of a stereo recording and store them once, together with level information. Remove sounds inaudible to the human ear, either due to frequency, or because they are drowned out by louder ones. Different levels of compression mean different quality of sound Lossless: FLAC, ALAC
52
The audio equivalent of vector graphics.
MIDI The audio equivalent of vector graphics. A MIDI file is a set of instructions that is used to play music. MIDI files are resolution independent so the quality of reproduction will be determined by the samples used for each instrument.
53
Storing Video
54
Determined by: Frame size Frame rate
Video file size Determined by: Frame size Frame rate Compression used for images and sound Video is effectively lots of graphics and audio. Similar storage systems are used.
55
Video compression uses both intra-frame and inter-frame compression.
Intra-frame compression takes each frame in the video sequence individually and compresses it. Inter-frame compression takes a series of frames at a time and compresses them in a single block. If there is a sequence of frames where nothing much changes then this will compress much more efficiently as only the changes from one frame to the next need to be stored.
56
Past Paper Questions
57
2017 paper Q1 State the range of positive and negative numbers that can be represented using 16 bit two’s complement representation. to (216-1) - 1 = -32,768 to +32,767
58
2017 paper Q3 3. A stereo sound file lasting 2 minutes with a sample rate of 96 kHz and sample depth of 16 bits is stored on a computer. Calculate the storage size of the uncompressed sound file. Show all working and express your answer in appropriate units × 120 × 2 × 16 = /8 = /1024 = /1024 = 43∙9 Mb
59
2017 paper Q14b 14b. Catherine has designed a black and white logo. There is both a bitmapped and vector graphic of the logo shown below. Catherine wants to move the ears of the cat closer together. State whether this task is easier to do with the bitmapped or the vector graphic. Explain your answer. (i) Vector is best because: You can drag individual objects without affecting others The ears could be grouped as a set of objects Objects can be layered The attributes of the ears can be changed
60
2017 paper Q14b(ii) (ii) Describe the effect on the file size of adding the star to both the vector and bitmapped graphic. Adding detail increases the size of a vector graphics file. A bitmap would stay the same.
61
2017 paper Q15c 15c. A mobile phone should be capable of capturing high quality video. One characteristic that would be considered would be bit depth. Describe the difference between a bit depth of 16 bits and that of 24 bits for the quality of video. 224 ( ) colours is better than 216 (65536) colours 16 million colours is often quoted a s the number of colours which can be distinguished by the human eye.
62
2017 paper Q15d Describe how video is compressed using interframe and intraframe compression. (ii) The effectiveness of video compression can depend on the content that is being captured. For example, videoing someone sitting singing a song on stage will compress differently when compared to videoing a high energy dance performance with a group of dancers. Explain the effectiveness of interframe compression for these different performances. (i) Interframe stores blocks of frames, compressing the video using repeated patterns within a block Intraframe stores each frame individually (ii) Interframe compression will be more efficient for the singer as the fact that there is much less change from one frame to the next so there are more repeated patterns from one frame to the next. Intraframe would be more appropriate for the dance performance
63
2016 Q1 1. A real number is stored using 32-bit floating point representation. The mantissa is allocated 24 bits and 8 bits are allocated to the exponent. Describe the effect if the allocation is changed to a 16-bit mantissa and a 16-bit exponent. The increase in exponent size will increase the range of numbers which can be stored but the decrease ion the size of the mantissa will reduce the precision of the numbers stored.
64
2016 Q2 2. Nadia wishes to store a video clip that is 24 frames per second, duration is 95 seconds and it has a resolution of 1280 × 720 with a colour depth of 16 bits. Calculate the storage requirement for the uncompressed video clip. Show all working and express your answer in appropriate units. 95 × 24 × 1280 × 720 × 16 (no of frames × resolution × bit depth) = = bytes = Kbytes = Mbytes = 3·914 Gb
65
2016 Q12c Emma records a vocalist singing the voice track for a new recording. Describe how increasing the sample rate and depth at the time of recording would improve the quality of this sound file. Describe a compression technique that reduces the file size for sound. (i) Increasing the number of samples per second increases the ability to store more information about the sound Increasing the number of bits per sample increases the range of sounds which can be stored. (ii) Remove frequencies not heard by humans. Store stereo as one sound and only store the volume information for each channel. Remove the quieter of two simultaneous sounds
66
2015 Q1 1. Convert the decimal number −120 to binary using 8 bits. 120 in binary = Invert: Add
67
2015 Q13b (b) Describe how compression reduces the file size of videos. Find repeated blocks of pixels or patterns in each video frame and store them once, along with their frequency. (RLE / LZW) Identify areas in each frame where averaging shades of colour will cause least change to the image. (JPEG) Use key frames and only store the differences between them. (MPEG)
68
2015 Q15c(ii) (ii) A photograph can then be edited so that the customer can view it with a range of hair styles and colours. This photograph could be a bitmap or vector graphic. Select one type of graphic and explain why it is suitable for this purpose. Bit mapped graphics would be best because they can be edited in fine detail at pixel level, and give more realistic images which are not made up of objects. Vector graphics could be used with the advantage that objects can be layered and edited individually and the images are resolution independent so never exhibit pixelation.
69
2015 Q15d (d) The hair salon also has some video clips stored on their computer that they use to train staff. Calculate the uncompressed file size of one of these video clips which is 90 seconds long and was captured at 25 frames per second with a resolution of 260 by 200 pixels and colours. State your answer in appropriate units and show all working. 90 sec × 25 frames × 260 × 200 pixels × 24 bits = 2,808,000,000 bits = 351,000,000 bytes = KB = MB
70
If you have any questions about tonight’s session please ask.
You will find the recording of this and all the other sessions on SCHOLAR. Please leave us feedback on tonight’s session: Thank you for taking part. Just close your browser to leave the session.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.