Higher Computing Science Storing Information

Slides:



Advertisements
Similar presentations
Information Representation
Advertisements

Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
The Binary Numbering Systems
Comp 1001: IT & Architecture - Joe Carthy 1 Review Floating point numbers are represented in scientific notation In binary: ± m x 2 exp There are different.
Data Representation Computer Organization &
Data Representation COE 205
Connecting with Computer Science, 2e
Copyright 2003 Monash University IMS5401 Web-based Information Systems Topic 2: Elements of the Web (d) Digital representation.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 12 Data.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Chapter 2 Data Representation. Define data types. Visualize how data are stored inside a computer. Understand the differences between text, numbers, images,
Higher Computing Data Representation.
Computer Systems Nat 4.5 Computing Science Data Representation Lesson 4: Storing Graphics EXTENSION.
Computing Higher - Unit 1… Computer Systems 1 Higher Computing Unit 1 – Topic 1 Data Representation.
Computers Organization & Assembly Language
CSCI-235 Micro-Computers in Science Hardware Part II.
Computers and Scientific Thinking David Reed, Creighton University Data Representation 1.
IT253: Computer Organization
Chapter 11 Fluency with Information Technology 4 th edition by Lawrence Snyder (slides by Deborah Woodall : 1.
Higher Computing Computer Systems S. McCrossan 1 Higher Grade Computing Studies 1. Data Representation Data Representation – Why do we use binary? simplicity,
Shawlands Academy Higher Computing Data Representation.
Data Representation CS280 – 09/13/05. Binary (from a Hacker’s dictionary) A base-2 numbering system with only two digits, 0 and 1, which is perfectly.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Data Representation The method of data representation in a computer system depends upon the type of data which is being used. Three types of data are considered.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
7/11/20081 Today’s Agenda Friday 6 th Nov Revision of certain topics Floating point notation Excess Notation Exam format Interim Report.
Chapter 1: Data Storage.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Int 2/ Higher - Data Representation - 1 Why use Binary? It is a two state system (on/off) which makes it simple to operate Even if degradation of current.
Data Representation The storage of Text Numbers Graphics.
Computer Systems Nat 4.5 Computing Science Data Representation Lesson 4: Representing and Storing Graphics EXTENSION.
CSCI-100 Introduction to Computing Hardware Part II.
Data Representation. What is data? Data is information that has been translated into a form that is more convenient to process As information take different.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Software Design and Development Storing Data Part 2 Text, sound and video Computing Science.
 Computers are 2-state devices › Pulse – No pulse › On – Off  Represented by › 1 – 0  BINARY.
Software Design and Development Storing Data Computing Science.
DATA Unit 2 Topic 2. Different Types of Data ASCII code: ASCII - The American Standard Code for Information Interchange is a standard seven-bit code that.
Chapter 1: Data Storage.
Computer Systems Nat 5 Computing Science Data Representation
Computer Science: An Overview Eleventh Edition
Image and Sound Representation
Storing Graphics Nat 5 Data Representation Lesson 4a: Storing Graphics
Data Representation.
Lec 3: Data Representation
Denary to Binary Numbers & Binary to Denary
Level 3 Extended Diploma Unit 19 Computer Systems Architecture
Level 3 Extended Diploma Unit 19 Computer Systems Architecture
Computer Systems Nat 4/5 Data Representation Lesson 4:
Binary Representation in Audio and Images
Computer Science Higher
Chapter 3 Data Storage.
BTEC NCF Dip in Comp - Unit 02 Fundamentals of Computer Systems Lesson 10 - Text & Image Representation Mr C Johnston.
Intermediate 2 Computing
Data Representation.
Representing Images 2.6 – Data Representation.
Web Design and Development
Ch2: Data Representation
Computer Systems – Unit 1
Chapter 2 Data Representation.
Why use Binary? It is a two state system (on/off) which makes it simple to operate Even if degradation of current occurs (ie a slight drop in voltage)
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Computer Systems.
Computer Systems Nat 4.5 Computing Science Data Representation
Computer Systems Nat 4/5 Data Representation Lesson 4:
WJEC GCSE Computer Science
Presentation transcript:

Higher Computing Science Storing Information Welcome to the first homework session for Higher Computing Science

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

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

Storing Numbers

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: 2 45 -3478 0 4 -385 3 -5

Human (Decimal) system 104 103 102 101 100 Ten Thousands Thousands Hundreds Tens Units 1 3 5 6 1 × 1000 + 3 × 100 + 5 × 10 + 6 × 1 = 1356

Binary system 27 26 25 24 23 22 21 20 128s 64s 32s 16s 8s 4s 2s Units 1 32 + 2 + 1= 35

Binary system 27 26 25 24 23 22 21 20 128s 64s 32s 16s 8s 4s 2s Units 1 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1= 255 (28 = 256)

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) = 0001 0011 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 (32 + 15) = 0010 0011 base 2

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.

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 113-64 = 49 25=32 49-32 = 17 24=16 17-16 =1 128 64 32 16 8 4 2 U 1 1 1 1

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.

Converting Decimal to Binary Convert 113 to binary = 1110001 2 113 R 56 1 28 14 7 3

Preparation question 1 State the minimum number of bits needed to represent the range of positive whole numbers from 0 to 16777215. 0 to 16777215 = 16,777,216 numbers 210 = 1024 220 = 1,048,576 224 = 16,777,216 So 24 bits needed You will need a calculator in the exam.

Preparation question 2 State the largest whole number that can be stored as a 10-bit positive integer. 29 = 512 10 bits needed 210 = 1024 11 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

State the number of bits required to store 16777216 colours. Preparation question 3 State the number of bits required to store 16777216 colours. 224 = 16,777,216 24 bits (colours numbered 0 to 16777215)

Negative Integers

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 2 + 1 = 3

Two’s Complement (8 bits) 27 26 25 24 23 22 21 20 -128s 64s 32s 16s 8s 4s 2s Units 1 -128 + 2 + 1 = -125

Two’s Complement (8 bits) 27 26 25 24 23 22 21 20 -128s 64s 32s 16s 8s 4s 2s Units 1 -128 + 8 + 2 = -118

Converting negative numbers to Two’s Complement Establish the bit length required Convert positive number to binary Complement the binary number Add 1

Convert -3 to 8 bit two's complement +3 = 00000011 Complement 11111100 Add 1 +1 Result 11111101 (-128 +125)

Convert -35 to 8 bit two's complement +35 = 00100011 Complement 11011100 Add 1 +1 Result 11011101 (-128 + 93)

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 - 128 For n bits the range would be: 2n-1-1 to - 2n-1 Remember 2^7 is 128-1 ie 2^ 8 -1

Preparation question 4 Early versions of Turbo Pascal ran on 16 bit machines and had a built in constant called MaxInt. Its value was 32767. 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 65536 integers. (2^16 = 65536) 16 bits gave a range of -3268 to +32767 It also had a LongInt constant which had a value of 2147483647 (32 bit two's complement).

Real Numbers

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. 12.67 000.0045 -45.7 -23.99656

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 = 1 + 0.25 + 0.25+ 0.125

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.

Scientific Notation You will be familiar with how numbers like this are stored in the decimal system: 1.34 × 103 Exponent Mantissa = 1340

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 = 0.00134 When very large or very small numbers are being represented then this system stores them with a limited degree of accuracy.

Floating Point Notation Floating point notation uses a similar system to decimal scientific notation. 0 011 1101 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.

Floating Point Notation Positive real numbers 0 011 1101 Sign Bit Mantissa Exponent = + 23 × .1101 = 110.1 = 6.5

Floating Point Notation Negative real numbers 1 101 1001 Sign Bit Mantissa Exponent = - 2-3 × .1001 = - .0001001 = - 0.0351562

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

Number Range in Floating Point notation 1 101 1001 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.

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.

Storing Text

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 0000000 to 0011111 ( 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.

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

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

Storing Graphics

Bitmapped Graphics Bitmaps are a grid of bits to store the information about the colour of each pixel in an image. 10101010 10001110 11111100 01100000 11110001 11110010 1111000 00011111 The bit-depth of an image refers to the number of bits used to store the colour of each pixel.

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 (16777216) Resolution = total number of pixels in the image So long as bit depth and resolution remain constant, image sixe also does irrespective of content.

Graphics file size example File size = resolution × bit-depth Example Resolution: 2 × 3 inches at 600 dots per inch (DPI) 600 × 600 × 2 × 3 = 2160000 pixels Bit-depth: 256 colours = 8 bits 2160000 × 8 = 17280000 bits = 2109 KB = 2.05 MB I'm afraid we are stuck with the US measurement system here.

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 0000 0000 0000 0000 0000 0000 FF white 1111 1111 1111 1111 1111 1111 green 0000 0000 1111 1111 0000 0000 80 half green 0000 0000 1000 0000 0000 0000

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 https://vimeo.com/3750507

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

Storing Sound

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

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

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.

Storing Video

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.

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.

Past Paper Questions http://www.sqa.org.uk/pastpapers/findpastpaper.htm?subject=Computing+Science&level=NH

2017 paper Q1 State the range of positive and negative numbers that can be represented using 16 bit two’s complement representation. -216-1 to (216-1) - 1 = -32,768 to +32,767

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. 96000 × 120 × 2 × 16 = 368 640 000/8 = 46 080 000/1024 = 45 000/1024 = 43∙9 Mb

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

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.

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 (16777216) 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.

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

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. http://www.sqa.org.uk/pastpapers/papers/papers/2016/NH_Computing%20Science_QP_2016.pdf

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) = 33619968000 = 4202496000 bytes = 4104000 Kbytes = 4007.8125 Mbytes = 3·914 Gb

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

2015 Q1 1. Convert the decimal number −120 to binary using 8 bits. 120 in binary = 0111 1000 Invert: 1000 0111 Add 1 1000 1000 http://www.sqa.org.uk/pastpapers/papers/papers/2015/NH_Computing%20Science_QP_2015.pdf

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)

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.

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 16777216 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 = 342773.4375 KB = 334.73 MB

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: https://www.surveymonkey.com/s/SCHOLARhomework Thank you for taking part. Just close your browser to leave the session.