Presentation is loading. Please wait.

Presentation is loading. Please wait.

Binary Arithmetic In today’s lesson we will look at: a reminder of how binary works adding binary numbers overflow complements negative numbers and subtraction.

Similar presentations


Presentation on theme: "Binary Arithmetic In today’s lesson we will look at: a reminder of how binary works adding binary numbers overflow complements negative numbers and subtraction."— Presentation transcript:

1 Binary Arithmetic In today’s lesson we will look at: a reminder of how binary works adding binary numbers overflow complements negative numbers and subtraction

2 Denary The number system most of us use is based on tens: 1234 1010001100 x10 As we move left, the column headings increase by a factor of ten In each column we can have ten different digits (1 to 9 and 0) This number is: 1 x 1000 + 2 x 100 + 3 x 10 + 4 x 1 That gives us one thousand two hundred and thirty four

3 Binary The binary system is based on the number two: 1011 2814 x2 As we move left, the column headings increase by a factor of two In each column we can have two different digits (0 or 1) This number is: 8 + 2 + 1 = 11 It’s still eleven, it’s just written down differently

4 Largest Numbers 0009 1010001100 Binary behaves like ordinary numbers in lots of ways – think of the largest number we can write with a given number of digits... 0099 1010001100 0111 2814 Binary behaves in the same way – e.g. 111 is seven.

5 Multiplying By 10 0025 1010001100 In denary, if we multiply by 10 then the digits shift one place to the left. 0250 0011 2814 In binary, if we multiply by 10 then the digits shift one place to the left 0110

6 Adding Binary Numbers The same is true of adding numbers. Think about what happens when you’re adding two normal numbers: –we line the numbers up so that the units are aligned –we start on the right and add up each column separately –if the column total is 10 or more then we need to carry Adding up in binary is exactly the same!

7 Example 0110 2814 In this case, adding is easy because there’s nothing to carry 0001 0111 How can we check the answer? + 110 = six, and 1 = one – if we add six and one together we should get seven = 111.

8 Example 0110 2814 In this case, we have two ones in the twos column – what do we do? 0011 1 001 + 1 1 + 1 = 10, so we need to carry one 1

9 Example 0110 2814 Computers use a fixed number of bits to represent numbers – usually 8, 16, 32, or 64 bits. 1011 001 + What’s happened here? 01 There’s an extra digit – the answer is too big to fit! This is called overflow.

10 Overflow Overflow is the name we give to the situation where a number is too big to fit into the allocated numbers of bits. This is an undesirable situation because we don’t really know what the answer is. This can also happen when we’re sampling data from the real world – e.g. if we try to record a sound that’s too loud. Computers can get around this problem by using multiple bytes to store numbers.

11 Subtraction You can subtract binary numbers in the same way as we subtract ordinary numbers, e.g. by borrowing if the bottom digit is smaller than the top one. There is also another method that uses complements. It uses the idea that subtracting a number is the same as adding a negative number – e.g. taking 2 away from 6 is the same as adding -2 to 6.

12 Complements Negative numbers in binary are often represented using something called a twos-complement. A ones-complement takes all of the digits and swaps 1s for 0s and vice versa – e.g. for the number 3: 00111100 A twos-complement just takes this number and adds one to it: 1101 This is -3 in twos- complement form

13 Example 0111 2814 Imagine we want to subtract one from seven: 1111 110 + 01 There’s an overflow digit – when we are subtracting we just discard it. The answer is 0110 = six. Here’s the seven: One would be 0001; the 1s-complement would be 1110, and the 2s-complement would be 1111.


Download ppt "Binary Arithmetic In today’s lesson we will look at: a reminder of how binary works adding binary numbers overflow complements negative numbers and subtraction."

Similar presentations


Ads by Google