Presentation is loading. Please wait.

Presentation is loading. Please wait.

Number Systems Revision of conversations What is a register Addition Complementation.

Similar presentations


Presentation on theme: "Number Systems Revision of conversations What is a register Addition Complementation."— Presentation transcript:

1 Number Systems Revision of conversations What is a register Addition Complementation

2 Revision of conversions DecimalBinaryHexadecimal 10101 2 340 10 101110 2 10011111 2 38 16 450 10 C67 16 B21 16 44 10

3 Answers DecimalBinaryHexadecimal 21 10 10101 2 15 16 340 10 101010100 2 154 16 46 10 101110 2 2E 16 159 10 10011111 2 9F 16 56 10 00111000 2 38 16 450 10 111000010 2 1C2 16 3175 10 110001100111 2 C67 16 2849 10 101100100001 2 B21 16 44 10 101100 2 2C 16

4 Home Work Convert the following DecimalBinaryHexadecimal 111011 2 55 10 000011 2 01010100 2 A9E 16 199 10

5 What is a Register? A small amount of very fast computer memory Speed up computer programs. Store most commonly used values, Computers load information into the registers, and then load it back to the main memory (load-store architecture)

6 Registers If we have a 5 bit register the maximum number of bits it can store is 5 Since it can hold 5bits we could have 2 5 combinations (32) The range of the register would be 0 – 2 5-1 = 0 - 31

7 Working with Registers If we had a 12 bit register how many bits could it hold? How many combinations would the register be able to hold? What would the range of the register be?

8 Home Work Find the following for registers A, B and C 1. How many bits would each one hold? 2. How many combinations could be made in each register? 3. What would the range of numbers be for each one? A.10 B.8 C.14

9 Addition We could perform addition on binary numbers Here are some examples; 0+ 1+ 010 1 1 01110 11

10 REMEMBER If we remember the following rules we will have no problems when performing additions 0 + 0 =0 0 +1=1 1 + 0 =1 1 + 1 =10 1 + 1 + 111 0 1 1 2 3

11 Trying out additions 100+1001+ 111+ 0110011 001

12 Answers 100+1001+ 111+ 0110011 001 1111100

13 Home work 1110+0101+ 1101+ 11110110 0100 0101+1000+ 1110+ 01111001 1010

14 Complementation Complementation is a used to represent positive and negative numbers. In binary This system requires numbers to be represented by a fixed number of bits. There are two forms of complementation, one’s complement and two’s complement.

15 Ones Complement One’s complement is used to represent negative numbers Lets say we have 45 10 When using 8 bits 45 10 = 00101101 2 If we change 45 10 to -45 10 The binary representation changes by converting 0s to 1s and 1s to 0s; 00101101 2 11010010 2. after ones complement

16 Examples Change the following to negative binary numbers using one’s complement DecimalBinaryOne’s Complement 109 10 229 10 64 10 89 10

17 Answers DecimalBinaryOne’s Complement 109 10 1101101 2 0010010 2 229 10 11100101 2 00011010 2 64 10 1000000 2 0111111 2 89 10 01011001 2 10100110 2

18 Two’s Complement Two’s complement allows us to perform subtractions with binary numbers With two’s complement we start converting 1s to 0s and 0s to 1s after the first 1 Lets take the previous example of -45 10, DecimalBinaryTwo’s complement 45 10 00101101 2 11010011 2

19 Another example Lets say we had the number 17 10 and we want to change it to a -17 in two’s complement First we convert 17 10 to binary using an 8 bit register = 00010001 2 Starting after the first 1 we convert the bits = 11101111 2

20 Examples Change the following negative numbers to binary using two’s complement and an 8 bit register ; DecimalBinaryTwo’s Complement -10 10 -42 10 -55 10 -60 10

21 Answers DecimalBinaryTwo’s Complement -10 10 00001010 2 11110110 2 -42 10 00101010 2 11010110 2 -55 10 00110111 2 11001001 2 -60 10 00111100 2 11000100 2

22 Home Work Convert the following negative numbers into binary using one’s and twos complement; DecimalBinaryOne’s Complement Two’s Complement 56 10 89 10 67 10 21 10 49 10

23 Numerical Overflow An overflow is when something doesn’t fit in a certain space Numeric overflow is when the storage for a calculation is too small to hold the result For example we have an 8 bits register, if we add two binary numbers and the result turns out to be 9 bits it would not fit in the register

24 Example Let’s say we have an 8 bit register Add the following; Do we have an overflow? 11111111+ 10101010

25 Numerical Overflow When we have a numeric overflow we will have an error in our calculation When we have an overflow we would need to remove the extra bit at the start of the number Lets say we had a 7 bit register and the result of a calculation is 11001100 the actual answer would be 1001100

26 Example Let’s say we have a 7 bit register Add the following; Do we have an overflow? Actual answer = 1101111 + 1101101

27 What is Bit Shifting? Bit shifting is the process of moving all the bits in a binary number We have two shifts 1. A right shift 2. A left shift The right shift would divide the number while the left would multiply it

28 Right Shift The right shift is used for If we shift the byte 00110111 2 left once, we get 01101110 2. If we shift 10110011 2, right by three places, we get 00010110 2. Notice in the right-shift example that bits that are shifted out of the byte are lost. This also occurs with left-shifting: if any bits are shifted outside of the "boundaries" of the type in use (eight bits, for a byte), they are lost.

29 Left Shift

30 Right Shift

31 Ranges


Download ppt "Number Systems Revision of conversations What is a register Addition Complementation."

Similar presentations


Ads by Google