Presentation is loading. Please wait.

Presentation is loading. Please wait.

Negatives, Addition, Subtraction

Similar presentations


Presentation on theme: "Negatives, Addition, Subtraction"— Presentation transcript:

1 Negatives, Addition, Subtraction
Binary Negatives, Addition, Subtraction

2 Storing Negative Integers
Another method is 2s Complement -75 64 32 16 8 4 2 1 128 -128 1 1 1 1 1 =-75

3 2s Complement Conversion
-117 Stage 1 : work out 117 in binary 128 64 32 16 8 4 2 1 Stage 2 : Reverse the 0’s and 1’s -128 64 32 16 8 4 2 1 1 Stage 3 : Plus 1

4 Binary Addition In binary these are the possible sums… 0 + 0 = 0
0 + 1 = 1 1 + 0 = 1 1 + 1 = 0, carry 1 = 1, carry 1 = 0, carry 0, carry 1

5 Binary Addition Example 1
= 89 128 64 32 16 8 4 2 1 75= 14= Carry 89 1 1 1 1 1 1 1

6 Binary Addition Example 2
= 136 128 64 32 16 8 4 2 1 79= 57= Carry 136 1 1 1 1 1 1 1 1 1

7 Binary Addition Example 3
= 150 128 64 32 16 8 4 2 1 75= Carry 150 1 1 1 1 1 1 1 1

8 Binary Addition Example 4
128 64 32 16 8 4 2 1 26 138 87 251 Carry 1 1 1 1 1 1 1 1 1 1 1

9 Binary Addition Example 5
128 64 32 16 8 4 2 1 109 39 45 Carry 1 1 1 193 1 1 1 1 1 1

10 Binary Addition Example 6
128 64 32 16 8 4 2 1 151 42 31 Carry 1 1 1 224 1 1 1 1 1 1

11 Binary Subtraction CPUs can’t subtract, they can only add! 75-14=61 The same as… 75+(-14)=61 Positive + Negative = Negative To do this we need 2s Complement -128 64 32 16 8 4 2 1

12 Binary Subtraction Example 1
75-14=61 75+(-14)=61 -128 64 32 16 8 4 2 1 75= -14= 61 1 1 1 1 1 1 1 1

13 Binary Subtraction Example 2
91-18=73 91+(-18)=73 -128 64 32 16 8 4 2 1 91= -18= 73 1 1 1 1 1 1 1 1 1 1


Download ppt "Negatives, Addition, Subtraction"

Similar presentations


Ads by Google