On Fri, Jun 05, 1998 at 03:10:10PM -0400, Barry Cooper wrote: > I keep running across references to 2's complements, does anyone have a > relatively simple explanation? A 2's complement is a variation on 1's complement; the 1's complement of a binary number is just the number with all bits inverted, e.g. 01101010 has a 1's complement of 10010101 where each bit is individually toggled. Now a 2's complement is a 1's complement plus 1, so the 2's complement of the first number is 10010110 Note that a 1 value has been added to the number (causing overflow into the second bit). The value of 2's complement derives from the fact that the 2's complement of zer o is also zero (try it out, ignore the overflow from the high order bit). This makes it a good operation to use for negating a binary number, and is the representation used by 99.9% of all computer architectures for representing sign ed numbers (where negative zero equals zero). -- Clyde Smith-Stubbs | HI-TECH Software Email: clyde@htsoft.com | Phone Fax WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885 PGP: finger clyde@htsoft.com | AUS: +61 7 3354 2411 +61 7 3354 2422 --------------------------------------------------------------------------- HI-TECH C: compiling the real world.