Binary Arithmetic
Learning Objectives 3.1.4 Be able to perform binary arithmetic [add, subtract, multiply] and understand the concept of overflow
Addition… 26 + 36 = 62… why? Remember that the position of the number is related to it’s value, so a carry in denary is worth 10 units. It’s the same in binary – remember the position relates to it’s value! 10’s 1’s 2 6 3 2+3+1 = 6 6+6 = 1 ten 2 units Carry 1 ten
Binary Addition Lets’ try 101 + 101 = 8’s 4’s 2’s 1’s 1 2+0+0 = 1 lot of 2 Carry 1 lot of 8 4+4 = 8 Carry 1 lot of 2 1+1 = 2
Some more examples - Try the following – 0101+0100 = 0111+0001 = 0101+0010 = 1010+0010 = This might cause a problem… 1111+0001 = 1001 1000 0111 1100 10000
Overflow! That’s what happens when “you run out of bits” If you try to store a number that is larger than the number of bits you have, you create an Overflow error. These are bad! Normally the result is treated as a negative!
Binary subtraction. Computers can only ADD… …well that’s a problem. What about … 5 + -3 = 2? We can work with that!
Subtraction…in binary Lets try 0101 – 0011 5 – 3 We know the answer should be 2. We need the Two’s compliment for -3. Flip all the bits 1100 Add 1 to answer 1101 8’s 4’s 2’s 1’s 1 IGNORE ANY CARRY!
Some more examples… Try these – 8 - 7 = 12 – 4 = 5 – 5 = 7 – 3 = 7 – 3 = 6 – 2 =
And finally – Multiplication. How have you been taught to multiply numbers together? For example 5 * 11 = 55? How did you work it out? Show method on board Now try 18 * 36 = … 648
What ever your method…try this https://youtu.be/ZS4Ql5vQbRY
Remember why you move over! Remember when you move over a column in DENARY it’s because the number is 10 times greater! When we do the same in binary it’s because it is TWICE as large!
https://youtu.be/ZS4Ql5vQbRY Watch this example… Be ready to talk about it afterwards! https://youtu.be/ZS4Ql5vQbRY
3 x 5 = 15. 16 8 4 2 1 1 1 1 1 1 1 1 1 Start using the method we have seen. From the right. Remember we are multiplying 2 x 1 when we move columns. So the answer has to be stored in the 2 column! Add up everything. We move over to the 2’s. 0 x anything is always 0. We have now finished with the least significant bit of 5. the 1’s. We have now finished with the 2’s. We move to the 4’s 4 x 1 = 4 4 x 2 = 8
Examples.. Now try these… 2 x 4 = 0010 * 0100 = 3 x 8 = 0011 * 1000 =
Plenary HOW do you add 2 binary numbers together? What is overflow? Can you get overflow when subtracting? HOW do you subtract one binary number from another? HOW do you multiply 2 numbers together?