Loading...
Hello, my name is Mrs. Holborow and welcome to Computing.
I'm so pleased that you've decided to join me for the lesson today.
We are going to be exploring how we can multiply and divide binary numbers.
That might sound a bit scary but don't worry, we're gonna work through it together.
Welcome to today's lesson from the unit "Representation of numbers." This lesson is called "Binary shifts" and by the end of today's lesson you'll be able to perform binary shifts to multiply and divide binary numbers, but also recognise the errors this may introduce.
Shall we make a start? We will be exploring these keywords throughout today's lesson.
Binary shifting.
Binary shifting.
When binary digits are moved left or right, multiplying or dividing them by powers of 2.
Overflow.
Overflow.
When a number is too large to be represented in the available binary digits.
Underflow.
Underflow.
When a number is too small to be represented in the available binary digits.
Today's lesson is broken down into three sections.
We'll start by using left binary shifting to multiply numbers.
We'll then use right binary shifting to divide numbers.
And then we'll finish by explaining overflow and underflow errors.
Let's make a start by using left binary shifting to multiply numbers.
Binary shifting is the process of moving binary digits to the left or right to change the value.
If you shift to the left, you multiply, and if you shift to the right, you divide.
Let's have a look at an example together.
We're going to look at multiplying the binary number 100 by the binary number 10.
In decimal, this is equivalent to 4 multiplied by 2.
We shift the binary digits to the left by one place value.
So have a look at my place value table.
At the moment I've got the binary number 100 in the table.
I'm going to shift the values one place to the left.
So you can see that 100 multiplied by 10 is equal to 1000.
And just to test that we've done that correctly, we can look at the decimal equivalent, which is 4 multiplied by 2, which is 8.
So we know that we've done this correctly.
You can use left binary shifting to multiply a binary number by 2, 4, 8, 16 and so on.
If you want to multiply by 4, you shift left by two places, so you can see two hops on the place value table.
So 100 multiplied by 100 is 10000.
And again, we can look at the decimal equivalence to make sure that we've done the calculation correctly.
Let's go through another example together.
What is 111 multiplied by 1000? Here we're multiplying the number by 8.
How many place values do you need to shift to get from 1 to 8? Maybe pause the video whilst you have a think.
That's right, Jun.
It's three hops or three places to the left.
This means that you need to shift the binary digits three places to the left.
So I've started by putting 111 in my place value table.
Time to check your understanding.
How many place values would you need to shift 111 to the left to multiply by 10000? Is it A, four; B, six; or C, eight? Pause the video whilst you have a think.
Did you select A? Well done.
We'd have to shift the place values four times to the left to multiply by 10000.
Let's go back to the example that we were looking at.
So we know that we're multiplying this number by 8 and that we need to shift the binary digits three place values to the left.
So I've taken my original first three values, 111, and I've shifted them three places to the left.
Remember, if we have any gaps, then we use 0s to fill those in.
So the answer is 111000.
And we can check that the calculation is correct by converting it to decimal.
So 7 times 8 is equal to 56.
And then we can use our knowledge of how to convert a binary number to decimal to check that we've got the correct answer.
So 32 plus 16 plus 8 is equal to 56.
Let's have a look at another example together.
This time I want to multiply 101 by 100.
This is multiplying the number by 4.
This means that we need to shift the binary digits two place values to the left.
Remember, 0s are used to fill the gaps when we shift the number along the place values.
Again we can check we are correct by looking at the decimal equivalents.
5 multiplied by 4 is 20.
16 plus 4 is equal to 20.
So it's correct.
Time to check your understanding.
What is the correct answer for the following multiplication calculation in binary? 10101 multiplied by 10.
Is it A, 1010; B, 10101; or C, 101010? Pause the video whilst you have a think.
That's right, C, 101010, is the correct answer.
We're now moving on to our first set of tasks for today's lesson and you're doing a fantastic job so far, so well done.
I'd like you to use left binary shifting to calculate the results for the following binary multiplications.
A, 1101 multiplied by 100.
B, 1010 multiplied by 100.
C, 1100 multiplied by 1000.
D, 101 multiplied by 1000.
E, 10010 multiplied by 100.
And F, 11001 multiplied by 1000.
Alex has got a really good tip.
"To check your answers, try converting the questions and answers to decimal." Pause the video whilst you complete the activity.
How did you get on with your calculations? Did you convert your answers to decimal to check? Let's have a look at the answers together.
So A, 1101 multiplied by 100 is equal to 110100.
B, 1010 multiplied by 100 is equal to 101000.
C, 1100 multiplied by 1000 is equal to 1100000.
D, 101 multiplied by 1000 is equal to 101000.
E, 10010 multiplied by 100 is equal to 1001000.
And lastly F, 11001 multiplied by 1000 is equal to 11001000.
Remember, if you've made any mistakes, you may want to go back and recap and have another go.
We're now moving on to the second part of today's lesson where we're going to use right binary switching to divide numbers.
In order to divide, you do the same thing as we did when we were multiplying, but this time you binary shift to the right.
Let's try this example together.
100 divided by 10.
So I've written the value 100 in my place value table.
You're dividing by 2 so you shift to the right by one place value.
So the answer for 100 divided by 10 is 10.
Again, like we did when we were multiplying, we can convert the values to decimal to check that we have done the calculation correctly.
So 4 divided by 2 is 2.
Time to check your understanding.
When dividing numbers in binary, you shift values to the left.
Is this true or false? Pause the video whilst you have a think.
That's right, it's false.
When dividing numbers in binary, you shift values to the right.
Shifting values to the left is used for multiplication.
You can divide any whole binary number by any divisor that is a power of 2.
You just right shift the appropriate number of places.
To divide by 2, you shift one place to the right.
To divide by 4, you shift two places to the right.
To divide by 8, you shift three places to the right, and so on.
Time for a check.
How many place values do you need to shift to the right in order to divide by 16? Is it A, two; B, three; or C, four? Pause the video whilst you have a think.
Did you select C? Well done.
In order to divide by 16, you have to shift four place values to the right.
Let's try another example together.
So this time we're dividing 1000 by 100.
In decimal, that's the equivalent of 8 divided by 4, which we know is 2.
How many place values do you need to shift to the right in order to divide by 4? That's right, Jun.
Two places.
So we're dividing two places, so we're going to shift two places right, which gives us the answer of 10.
We're now moving on to the second set of tasks for today's lesson, and I'd like you to use right binary shifting to calculate the results for the following binary divisions.
A, 110100 divided by 100.
B, 1010 divided by 10.
C, 1100 divided by 100.
D, 1100 divided by 10.
E, 101010 divided by 10.
And lastly F, 1101000 divided by 100.
Alex has got a good tip.
"Remember to check your answers, try converting the questions and answers to decimal." Pause the video here whilst you complete the activity.
How did you get on with your divisions? Did you find them any easier than multiplication or more difficult? Let's have a look at the answers together.
So A, 110100 divided by 100 is 1101.
B, 1010 divided by 10 is 101.
C, 1100 divided by 100 is 11.
D, 1100 divided by 10 is 110.
E, 101010 divided by 10 is 10101.
And lastly F, 1101000 divided by 100 is 11010.
Remember, if you need to pause your video to make any corrections, you can do that now.
You're doing a fantastic job so far, so well done, and you've learn to multiply and divide in a totally different number system.
Let's now move on to explain overflow and underflow errors.
Overflow and underflow are words used to describe when a number is too large or too small to be processed or stored in the allocated memory.
Overflow occurs when the result of a calculation is too large.
Underflow occurs when the result of a calculation is too small.
In this calculation, there are four bits allocated for the answer.
What is the largest number that can be stored with four bits? Maybe pause the video and have a quick think.
That's right, Jun.
1111 is the largest number that can be stored in four bits, which is the equivalent of 15 in decimal.
Let's see what happens when we try to add 1 to 1111.
Remember, there are only four bits of memory allocated for the answer.
So, using our binary addition rules, 1 plus 1 is equal to 10, so I'm going to put my 1 down into the carry column.
1 plus 1 is equal to 10 again, so I'm going to use the next carry column along.
1 plus 1 is 10 again.
And then I have 1 plus 1, which is 10.
Now we have a problem.
Can you spot what that problem is? An overflow error has occurred.
Because 1111 plus 1 is basically the decimal equivalent of 15 plus 1, which is 16, the result is too large to fit into our four binary digits, and the answer will be stored as 0000, which is obviously incorrect.
Laura says, "This error could cause problems, so it's important to check that you've allocated enough memory to the result." Laura is right.
Overflow errors can have severe consequences.
In 1996, the European Space Agency launched an unmanned rocket called the Ariane 5.
During the flight, a 64-bit number was converted to a 16-bit number.
The number was larger than 32,767, so an overflow error occurred.
The number error meant that the rocket had data stating that it was off-course.
The rocket boosters immediately overcorrected and caused a massive explosion.
Time to check your understanding.
Which one of the following calculations would cause an overflow if the result were to be stored in four binary digits? Is it A, 1101 plus 11; B, 1000 plus 101; or C, 101 plus 111? Pause the video whilst you complete your calculations and have a think.
That's right, the correct answer is A.
1101 plus 11 would cause an overflow error.
Underflow occurs when a number is too small to be stored in the allocated number of bits.
This may sound a bit strange, but a number is too small if it's too close to 0 for it to be represented.
For example, if you're working with a very small positive number and subtract something even smaller, the result might become so tiny that the computer rounds it to 0 because it can't store it accurately.
Aisha says, "It's like trying to measure something smaller than the smallest mark on a ruler." To avoid overflow and underflow errors, you can allocate more binary digits for the numbers.
However, adding more binary digits will require more storage space, so you need to decide what is more important, space or the resulting error from an overflow or underflow.
Let's have a look at an example together.
Here I've got the binary numbers 101 divided by 100, which in decimal is the equivalent to 5 divided by 4.
As we're dividing by 4, we need to shift two places to the right, so that gives us the answer 1.
But Aisha says, "It doesn't quite look right.
5 divided by 4 isn't 1, it's 1.
25." At this stage, you can only work with whole numbers or integers in binary.
In this case, the remainder is truncated.
This means that anything after the decimal place is discarded.
So in this case, the answer is 1, not 1.
25.
Time to check your understanding.
What will be the value of the truncated result of the decimal value 7 divided by 2 if the calculation is done with binary values? Is it A, 2; B, 3; or C, 4? Pause the video whilst you complete your calculation.
That's right, the correct answer is B, 3.
Remember, anything after the decimal place will be discarded.
Okay, it's now time for our final task of today's lesson and you've done a great job so far, so well done.
What I'd like you to do, please, is fill in the spaces using the terms on the right.
Pause the video whilst you complete the activity.
How did you get on? Did you manage to correctly fill in the gaps? Let's read through the answer together and you can check off whether you've got the answers correct.
Overflow and underflow happen when a number is too big or too small for the computer to handle with the memory that it has.
Overflow happens when there is a number so big that it can't be stored.
For example, trying to store the value 16 in four binary digits will cause an overflow, as the maximum value that it can store is 15.
Underflow happens when a number is so small that the computer treats it as 0.
To avoid these problems, you can use more binary digits to store the numbers.
But remember, using more binary digits takes up more storage space, so you need to decide what's most important.
If you need to pause your video here and make any corrections, you can do that now.
We've come to the end of this lesson and you've done a fantastic job, so well done.
Let's summarise what we've learned.
In binary, multiplication and division are performed by binary shifting a number to the left or right.
To multiply a number by 2, shift the number one place value to the left, backfilling with 0s.
To divide a binary number by 2, shift the number one place to the right.
Overflow and underflow happen when a number is too big or too small for the computer to handle with the memory it has.
I hope you enjoyed the lesson and I hope to see you again soon, bye.