August 31st, 2000, 03:42 AM
Join Date: Aug 2000
Time spent in forums: < 1 sec
Reputation Power: 13
How two's complement works:
Take positive number as binary value
Subtract 1 from it
Flip the bits
Thus, 6 goes:
The reasons for this are pretty arbitrary -- two's complement is an entirely artificial system for representing a negative number that's just used because it has some useful properties, namely:
1) You get as many negative as positive numbers
2) It's simple
3) Every positive number has a negative equivalent in the same number of bits (a stricter version of (1), really).
There are probably several other reasons for it that I haven't thought off of the top of my head.
Just out of interest, why do you need to know about two's complement for 'Beginner' web work? :-)