This is long. Ive had a few drinks, so ill amend (delete) this in the morning! (edit, re-reading your post, read my next post. ill leave this in for those interested...)
Its all about integer maths, and knowing when to overflow it.
i dont know how much you know...
an integer is a whole number (no decimals or fractions).
in basic binary, there has to be a method for denoting positive and negative numbers. this obviously takes 1 bit.
in normal pic integer maths, you have 0->255 range for an 8 bit variable. a word is 0-65535. but, as far as the processor is concerned, that is positive.
so to represent a negative integer on a pic processor, you loose 1 bit of accuracy... as you do not get 9 or 17 bit variables.
so, to describe a negative number, bit7 is used for an 8bit int, and bit 15 for a 16bit word (the last bit. remember there is a bit0).
now, there are 2 kinds of negative representation. 1 lends its self to easy understanding, and translating (perhaps even comparison, and other logic). whilst the other lends itself to addition and subtraction, and other maths.
1's compliment is the first kind.
basically, you describe the magnitude of the integer (, ie 20, 100, 42, etc) with 7 bits (bit0->bit6) and use the 8th bit (bit7) to describe the sign. this makes it easy for us humans (well, easy-ish) to understand. magnitude, and sign.
this means, that you can use all 8 bits if you are only ever using positive numbers. 1's compliment is only used for negative/positive numbers. this means compatibility needs to be maintained, ie a positive number is unaffected.
if you remove bit7, then you have the size of the bit. you can test the sign-bit, display the magnitude, etc.
the cool thing is: you can add 128, and you can have an off-set range which makes it easy to compare.
so, some examples:
120 = %01111000.
-120 = %11111000 (as far as the processor is concerned, thats 248)
so for that, direct comparison doesnt work:
-120 > 120 as far as the processor is concerned.
but, it is easy to understand.
now, you can offset the zero, by adding $80. this makes a "relative" 0 (at 128). the processor doesnt care where zero is. it will overflow variables as and when it needs to. you could have 255 as your zero, and remember when you output to add 1 (ie, when variable = 0, thats relative to 255, ie actually +1).
so, offset examples:
%01111000 (120)
+ %10000000 (128 = $80)
= %1111100 (248)
...
%11111000 (-120)
+ %10000000 (128 = $80)
=%101111000 (504)
now, a variable on a pic is only 8bits. so, when presented with 9bits, it "overflows" and truncates the most significant bit... ie the bit that has the highest value.
for the 9bit value above, a pic would return %01111000.
this has essentially made positive numbers negative, and negative numbers positive (if you didnt know that $80 has been added on).
the other way of looking at it is: 128($80) has become your "zero". so you have biased, or offset, the mathematics. now, this is complicated for humans to follow, however it makes binary comparison very easy:
%10000001 (129 (offset math +1))
%01111111 (127 (offset math -1))
for a integer comparison, 127 < 129 (offset math -1 < +1)
whereas before, -120 > 120 (no offset)
1's compliment, however, makes maths a pain:
%11111000 (-120)
+ %00000001 (1)
= %11111001(-121, whereas -120 + 1 should be -119)
This is where 2's compliment is better.
2's compliment makes more sense for negative numbers. its not easier to understand, but definately makes more sense.
a positive number is as normal.
when a number goes negative, it does a sort of reverse overflow.
this is complicated.
1) invert the bits.
ie:
%01111000 (120) will be our example
becomes:
%10000111 (135)... you can see bit7 represents sign again.
2) Add 1
%10000111 (135)
+ %00000001
= %10001000 (136)
now, again direct comparison doesnt work... -120 > 120.
but, filter out bit7, and you get: 120(+120) > 8 (-120, described by 7 bits)
2's compliment is essentially like 1's compliment, with the offset. however, positive numbers run from 0 upwards, meaning positive-only numbers can be described with 8bits.
negative mathematics works as well:
%10001000 (135, 2's comp -120)
+ %00000001
= %10001001 (136)
not obvious, but reverse the steps...
subtract 1:
%10001000 (135)
invert the bits:
%01110111 (119)
this means that -120 + 1 = -119!
and thats me about to fall asleep.
I hope this helps. do ask questions, and correct/update me where Im wrong.