Storing Negative Integers Another method is 2s Complement 64 32 16 8 4 2 1 128 128 1 0 1 1 0 1 0 1 75 128 32 16 4 175 2s Complement Conversion 117 Stage 1 work out 117 in binary ID: 730764
Download Presentation The PPT/PDF document "Binary Negatives, Addition, Subtraction" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Binary
Negatives, Addition, SubtractionSlide2
Storing Negative Integers
Another method is
2s Complement
64
32168421
128
-128
1
0
1
1
0
1
0
1
-75
-128+32+16+4+1=-75Slide3
2s Complement Conversion
-117
Stage 1 : work out 117 in binary
-128
64321684211000101
Stage 2 : Reverse the 0’s and 1’s
128
64
32
16
8
4
2
1
0
1
1
1
0
1
0
1
Stage 3 : Plus 1
1
0Slide4
Binary Addition
In binary these are the possible sums…
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1 1 + 1 = 0, carry 1 1 + 1 + 1 = 1, carry 1 1 + 1 + 1 + 1 = 0, carry 0, carry 1Slide5
Binary Addition Example 1
128
64
32
16842175=010010
1
1
14=
0
0
0
0
1
1
1
0
Carry
75 + 14 = 89
1
0
1
0
1
1
1
1
0
1
0
89Slide6
Binary Addition Example 2
128
64
32
16842179=010011
1
1
57=
0
0
1
1
1
0
0
1
Carry
79 + 57 = 136
0
0
0
1
0
0
0
1
1
1
1
1
1
1
1
136Slide7
Binary Addition Example 3
128
64
32
16842175=010010
1
1
75=
0
1
0
0
1
0
1
1
Carry
75 + 75 = 150
0
1
1
0
1
0
0
1
150
1
1
1
1Slide8
Binary Addition Example 4
128
64
32
16842126000110
1
0
138
1
0
0
0
1
0
1
0
87
0
1
0
1
0
1
1
1
251
Carry
1
1
0
1
1
1
1
1
1
1
1
1Slide9
Binary Addition Example 5
128
64
32
168421109011011
0
1
39
0
0
1
0
0
1
1
1
45
0
0
1
0
1
1
01
Carry
0
0
0
0
1
1
1
1
1
1
1
0
1
0
1
0
193Slide10
Binary Addition Example 6
128
64
32
168421151100101
1
1
42
0
0
1
0
1
0
1
0
31
0
0
0
1
1
1
11
Carry
0
0
0
1
1
1
0
0
1
0
1
1
1
0
224
1
1Slide11
Binary Subtraction
CPUs can’t subtract, they can only add!
75-14=61
The same as…
75+(-14)=61 Positive + Negative = NegativeTo do this we need 2s Complement-1286432168421Slide12
Binary Subtraction Example 1
-128
64
32
16842175=010010
1
1
-14=
1
1
1
1
0
0
1
0
75-14=61
75+(-14)=61
1
0
1
1
1
1
0
0
1
1
1
61Slide13
Binary Subtraction Example 2
-128
64
32
16842191=010110
1
1
-18=
1
1
1
0
1
1
1
0
91-18=73
91+(-18)=73
1
0
0
1
0
0
1
0
1
1
1
1
1
1
1
73