what is binary? - ark victoria academy 10 data... · web viewwhen converting using binary you start...

51
Computer Science Year 10 Data Representation Topic Contents 1) Binary to denary conversion 2) Binary Addition 3) Binary Subtraction 4) Binary addition and subtraction 5) Hexadecimal 6) Hexadecimal continued 7) Sign Magnitude 8) Two’s Complement

Upload: others

Post on 11-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Computer ScienceYear 10

Data Representation Topic

Contents1) Binary to denary conversion2) Binary Addition 3) Binary Subtraction 4) Binary addition and subtraction5) Hexadecimal 6) Hexadecimal continued7) Sign Magnitude8) Two’s Complement9) Sign Magnitude and Two’s Complement10) Exam Questions11) Exam Questions Continued12) Binary Images13) Binary Sound14) Answers

Lesson 1: Binary to denary conversion

Page 2: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

What is binary?

The binary system is known as a base 2 system. This is because:

there are only two digits to select from (1 and 0) when using the binary system, data is converted using the power of two. There are 8 bits (1-128) which make a byte

Our number system is called base 10 as there we use 10 digits 0 1 2 3 4 5 6 7 8 9 How does it work?

When converting using binary you start with the smallest binary place value (least significant bit LSB) on the right, number 1 and the largest binary place value (Most significant bit MSB) on the left, number 128. *Hint – If you have trouble remembering this, think about Beyoncé’s song “To the left to the left” so the MSB 128 is placed in the left hand side of the table.

The maximum number you can make using base 2 (binary)is 255 (actually 256 including 0)

To make the number 168 you put a 1 under all the number (BPV) that you are using and a 0 under

the number (BPV) you are not using

128 64 32 16 8 4 2 1

1 0 1 0 1 0 0 0

So 1010 1000 in binary is equal to 168 in denary.

Task 1:

1)What is binary?____________________________________________________________________________________________________________________________________

2)What kind of number system used in everyday life?______________________________________________________________________________________________________________________________________________________________________________________________________

3)What would the denary number 3 be in Binary?______________________________________________________________________________________________________________________________________________________________________________________________________

1

Binary place value

(BPV)

Page 3: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Task 2

2

Page 4: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

3

Page 5: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

4

Page 6: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 2: Binary Addition

When adding binary integers, you need to follow the rules below-

In practice they look like this-

Overflow

Overflow occurs when the result of a calculation requires more bits - place values - than are in the available range. This occurs when there are more than 9 bits in the answer of the calculation e.g. Questions

5

11001010 111011111+ 10111001

There are 9 bits in this answer therefore an Overflow error has occurred. When this happens you must show it in your calculation as +1 and CIRCLE it.

Page 7: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

6

Page 8: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

7

Page 9: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 3: Binary Subtraction

Binary Subtraction The subtraction of the binary digit depends on the four basic operations

For a binary number with two or more digits, the subtraction is carried out column by column as in denary

8

Page 10: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

subtraction. If you have 0-1 you must borrow 1 from the next most significant bit. Consider the following example.

The above subtraction is carried out through the following steps.

0 – 0 = 0

For 0 – 1 = 1, taking borrow 1 from the most significant bit and then 10 – 1 = 1

For 1 – 0 , since 1 has already been given, it becomes 0 – 0 = 0

1 – 1 = 0

Therefore, the result is 0010.

HINT* If you find you 0-1 when you get to the last most significant bit, the computer will automatically generate a 1

9

Page 11: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Questions

10

Page 12: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

11

Page 13: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

12

Page 14: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 4 Binary addition and subtraction

Complete the worksheets below *Remember the sums are now both binary addition and subtraction

13

Page 15: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

14

Page 16: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

15

Page 17: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

16

Page 18: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 5: Hexadecimal

Example) Convert Hex (1A) to binary code.

The general idea is that for every Hex character you have, you will need one 4bit binary system to convert it into binary code. To convert this example (1A) you will need to split the ‘1’ and the ‘A’ apart and put them into their own individual 4bit binary systems, as shown below.

Hex (1) holds the same value as the denary/decimal number 1 and is much the same in binary (0001) (This is how binary (1) is represented in a 4bit system). Following the same pattern: As you can see from the table above the example, Hex (A) is equal to the number 10 in denary/decimal and is also equal to 1010 in binary code.

In order to get the full binary code for Hex (1A), you now simply need to combine the two 4bit binary systems as you see them above. The example below shows you the result:

The two 4bit binary systems have now been combined and one 8bit binary system has now been created as a result. The key difference between the two 4 bit binary systems and the 8bit system, is that the numbers represented in denary now increment by the power of 2, (like in a normal binary to denary conversion table). However, the results of ‘1’ and ‘A’ follow the same pattern in the 8bit binary system as they did in the two 4bit binary systems. Therefore, you have the accurate binary code for Hex (1A). In theory, you can now work out the denary from the 8bit binary system as well.

Converting Hexadecimal to binary and then to denary, try the questions found over the page.

17

Page 19: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

TASK 1: CONVERT THE FOLLOWING HEX NUMBERS INTRO DENARY

Q1) 1B

Q2) AA

Q3) 1F

Q4) 2A

Q5) BB

Q6) 2E

Q7) 3A

Q8) CC

Q9) 3D

Q10) 4A

18

Page 20: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

TASK 2: CONVERT THE FOLLOWING HEX NUMBERS INTRO DENARY

Q11) DD

Q12) 4C

Q13) 5A

Q14) EE

Q15) 5B

Q16) 6A

Q17) FF

Q18) 7F

Q19) A0

Q 20) 8A

19

Page 21: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 6: Hexadecimal ContinuedQuestion: Base 10 to Base 16

20

Base 16 to 10

Page 22: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

21

Page 23: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 7 Sign and Magnitude

Sign Magnitude is the simplest method of representing negative numbers in binary.The MSB is replaced by a sign and magnitude symbol. If there is 1 under the MSB the number is Negative and if it is a 0 it is a positive number. 1= Minus 0 = Positive

-/+ 64 32 16 8 4 2 1

1 1 1 1 1 1 1 1

0 1 1 1 1 1 1 1

1) Convert these denary numbers to sign magnitude binary numbers. Remember to create the table.a) -74

b) -9

c) 102

2) Write the specified binary numbers in positive and negative forms:54

-54

1

-1

22

= -127

= 127

Page 24: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

127

-127

100

-100

21

-21

Write down the decimal values of the sign and magnitude numbers below:

0 1 0 1 1 0 1 1

1 0 0 0 0 1 1 1

1 0 0 1 1 0 0 1

1 0 0 0 0 0 0 0

Lesson 8 Two’s Complement

23

Page 25: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Two’s complement is another method of representing negative numbers using binary. The most significant bit is a negative numberIf there is 1 under the MSB the number is Negative and if it is a 0 it is a positive number. 1= Minus 0 = Positive

-128 64 32 16 8 4 2 1

1 0 0 0 1 1 0 1To make, let’s say -115 you add the binary values to -128 -128+8+4+1= -115Another way of performing Two’s Complement calculations is this method below

1- To make + 9 first write out 9 in the binary table9 0 0 0 0 1 0 0 1

2- Then swap the binary bits around (0 becomes 1 and 1 becomes 0)Complement 1 1 1 1 0 1 1 0

3- Then add oneAdd 1 1 1 1 1 0 1 1 1

-128+64+32+16+4+2+1=9Using you chosen method have a go at the questions below

1) Write the specified numbers in positive binary and two’s complement31

Complement

66

Complement

24

Page 26: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

100

Complement

Convert the negative two’s complement number back to positive:1 1 1 1 1 0 1 1

Complement

1 1 0 1 0 1 0 0

Complement

Lesson 9 Sign Magnitude and Two’s complement continued

25

Page 27: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Have ago at the questions below

26

Page 28: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 10: Exam Questions1) A car has many types of embedded systems.

(a) An embedded system processes binary numbers

The speed limit for some roads is 60 miles per hour.

Convert the denary number 60 to 8-bit binary.

____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

(ii) The car displays speed limits in denary. Convert the 8-bit binary number 0010 0011 to denary.

____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

(iii) The embedded system adds numbers in binary.

Complete the table to show the result of 0010 0011 + 0100 1010

27

2)

Page 29: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

28

3)

Page 30: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

29

4)

Page 31: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

30

5)

Page 32: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 11 Exam Questions Continued

31

1

2

Page 33: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

32

Page 34: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

33

4

Page 35: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

34

[2]

5

6

Page 36: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Add the following 8-bit binary numbers. 12 marks1. 010011102 + 001111002

2. 100111012 + 100011112

3. 110100112 + 010101102

4. 100100112 + 101110012

5. 111111102 + 101101012

6. 101111012 + 111001112

Subtract the following 8-bit binary numbers. 12 marks1. 110010102 - 100110102

2. 100111002 - 011110012

3. 110010112 - 100000112

4. 111000012 - 100111012

5. 100000012 - 011001102

6. 100100112 - 100001112

35

7

8

Page 37: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Lesson 12 Images

Vector graphics* Images can be stored in different ways in computers. When you create a

drawing in PowerPoint this is a vector graphic.

* Each line, circle or square is made up of simple properties such as position height and width.

Bitmap graphics* When you take a picture with a digital camera it is not made up of lines.

* To store this type of image on a computer the image is broken down into very small elements called pixels. Each pixel is set to one colour.

Pixel stands for Picture Element

Resolution* A Bitmap image is made up of a grid of pixels.

* An image could be 600 pixels wide by 400 pixels high.

* The resolution of this image would be 600X400.

* If the resolution is increased the quality i.e. more pixels, not the physical size, is increased and it takes up more of memory to store it.

Making an image file* We take the information from the image file and build an image data file

* We read left to right. Top to bottom.

Creating an Image* Each Pixel is given a binary

value

* Each value represents a different colour

* Using one bit per pixel allows only 2 values, 0 and 1

36

Page 38: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

1 = Black, 0 = White

Metadata* For the computer to interpret an image file and rebuild the picture it

must know some other things about this data file. For example…

* The resolution is 8X11

* The colour depth is 2 bits per pixel

* The colour of each pixel

* Meta data is data about data of the image and it contains the image width, image height, resolution and colour depth

*

How calculate file size in bits

Graded Exercises on Images

Grade 4+5 – Knowledge Recall

1) How many bits per pixel would be required for an image with a palette of 256 possible colours? [1]

37

Page 39: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

2) State two factors that affect the file size of a bitmap image. [2]

3) Additional metadata data is stored alongside the binary colour values for each pixel. Give two examples of metadata. [2]

4) Calculate the file size of the following images: [9] Show your working

Image Resolution

Number of colours

Colour depth in bits

File size in bits

File size in Bytes

Image 1 20 x 20 8

Image 2 10 x 10 8

Image 3 20 x 20 4

Extension

How does increasing the image resolution affect the file size?

Explain the relationship between image quality and file size

Grade 6+7 – Applying Questions

1. Look at the image below:

38

14px

Page 40: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

11011010 00100101 00110010 10100101

The first and second rows of the image above would be stored as 14 lots of 11011010:

11011010, 11011010, 11011010, 11011010, 11011010, 11011010, 11011010, 11011010, 11011010, 11011010, 11011010, 11011010¸ 11011010, 11011010

The same data could be stored as 00001110-11011010 (14 [binary 00001110] lots of 11011010) without losing any information required to piece together the image again. This is known as RLE or Run Length Encoding.

Record the data for the third, fourth and fifth lines in the image:

Line number Binary image data

1 00001110-11011010

2 00001110-11011010

3

4

5

Grade 7-8 – Exam Style Questions

39

10px

Page 41: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

1) Which icon image is greater in file size? (Show your working) [3]a. A 256 colour icon with dimensions of 50 x 50 pixelsb. A 16 colour icon with dimensions of 100 x 100 pixels

2) Convert the image into a data file [2]

Peter takes a high resolution picture with a digital camera. The picture is stored in a bitmap file.

(a) Tick one box in each row to show whether or not each of the following items must be included in the bitmap file.

[5]

(b) What is meant by the resolution of the picture?

......................................................................................................................................

......................................................................................................................................

...................................................................................................................................... [1]

c) How does the resolution affect the size of the bitmap file?

......................................................................................................................................

......................................................................................................................................

......................................................................................................................................

......................................................................................................................................

......................................................................................................................................

3) When might one want to decrease the colour depth for an image? [1]

40

Must be included Need not be included The names of the people in the picture The width of the picture in pixels The number of bits used for each pixel The number of people in the picture The colour of each pixel

Page 42: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Grade 8 and 9 Extension - Investigation:

This lesson has focused on Bitmap images. We also mentioned vector graphics. What are the differences between the two image types? Also investigate what is compression, the types of compression and how will that affect the image size, file size, image quality?

This exam question is based on the research on compression.

Ray wants to reduce the file size of his images and has been recommended to use compression. State two types of compression and advise Ray of the advantages or disadvantages of each method. [6]

Lesson 13 Sound

41

Page 43: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Sound can be represented in digital form as streams of 1’s and 0’s. Sound is caused by vibrations travelling through a medium such as air, water or a metal. Sound recordings convert the changes in air pressure into voltage changes. These are analogue recordings.

Sound SamplingSamples of the sound wave are taken at regular fixed intervals. This is called the sampling frequency. A high sampling frequency gives a more accurate reproduction on the analogue wave form.

An analogue-to-digital converter will capture a sound wave at regular time intervals. This recording is known as a sample.

For example, a sound wave like this can be sampled at each time sample point:

The sound recorded at each sample point is converted to its nearest numeric equivalent:

This data is then stored in a file for later use.

42

Page 44: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Sample rateSample rate is the number of samples recorded in any given period of time. The higher the sample rate, the closer the recorded signal is to the original.

Sample rate is measured in hertz.

The higher the sample rate, the larger the resulting file. As a result, sound files are often a compromise between quality and size of file.

An audio file is usually recorded at 44.1 kilohertz. This is high enough for good sound quality while keeping file size down to sensible levels.

Bit depth and bit rate* Bit depth refers to the number of bits used to record each sample.

* Just as with images, the higher the bit depth, the more accurately a sound can be recorded, but the larger the file size. Typical bit depths are 16 bit and 24 bit.

* Bit rate is simply a measure of how much data is processed for each second of sound. Bit rate is calculated by:

* Sample rate × bit depth

* As with sample rate, the higher the bit rate, the better quality of the recorded sound.

43

Exam spec questionA rapper uses a microphone to record his new song.a)An analogue to digital converter is used to change the sounds received by the microphone into a form that can be processed by a computer.[4](i) Complete the diagram to show sampling frequency and label both axis

Page 45: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

1. Look at the sound wave below and record the samples in the table beneath it. The first two are done for you. You can only plot a sample at an intersection. Use a ‘best-fit’ approach.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 146 8

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

2. Replot all of your figures on to the graph below and create a bar chart from the points. The first two points have been drawn for you.

44

Sampling Sound

Page 46: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

3. How accurately does this represent the original sound wave? Where are there inaccuracies in the digital reproduction of the wave?

4. What would you need to do in order to improve the accuracy of the recording?

5. In reality, each of the measurements on the Y axis would be given a binary value and that would be recorded in the audio data file. Using Table 1 below write out the binary values for each of the first ten samples given in Table 2. There are 16 sampling points on the Y axis so a minimum of four bits must be used in order to provide enough different bit patterns for each sampling point.

Y Bit value1 00012 00103 00114 01005 01016 01107 01118 10009 1001

10 101011 101112 110013 110114 111015 1111

Table 1

45

Page 47: What is binary? - Ark Victoria Academy 10 Data... · Web viewWhen converting using binary you start with the smallest binary place value (least significant bit LSB) on the right,

Sample 0 1 2 3 4 5 6 7 8 9

Value 6 8 11 13 10 4 6 14 2 4

Binary value 0110 1000

Table 2

The Binary Values in the third row above represent the data that would be stored to recreate this very short sound file of 10 samples.

6. What would be the file size in bytes of the 10 samples in Question 5?

The resolution is the accuracy with which the wave height is measured – the higher the resolution, the more accurate the measurement at a particular sample point.

7. What would the file size of samples in question 3 become if you increased the resolution to allow for 256 different points on the Y axis?

8. How would this affect the quality of the recording?

9. The sampling frequency is the frequency with which the measurements are taken – a higher sampling frequency means measurements are taken more often within the same period of time. How would this affect the quality of the recording?

10. Explain the relationship between the quality of playback and the file size.

46