View Single Post
  #12   Spotlight this post!  
Unread 07-12-2002, 09:59
Lloyd Burns Lloyd Burns is offline
Registered User
FRC #1246 (Agincourt Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Toronto
Posts: 292
Lloyd Burns is an unknown quantity at this point
My complements

I see many operational definitions of "complementing", which means "filling up".

The two's complement of a number is the number which, added to the number, gives 2 (that is, it "fills up" to the two. In binary, two is 10, the twos complement of '1' is '1', which adds to 0, with a carry.

In binary, if the number must be represented in n bits, then you probably mean to find the n-bit "two's complement", which means the number added to your number which gives a rollover to 'n' zeros and a carry (for the n+1st bit (or all zeros and a carry).

** Without resorting to bits ....

For a nibble (4 bits), which allows a 15(decimal) max before rollver (that is, the one bit in the fifth place means 16), the "two's complement" is the number which added to your number gives 16. If your number is 5, then 11 is the "twos complement" giving zeros in the four bits and a carry to a fifth.

** It works in decimal, too ....

The ten's complement of seven is three: add three to seven, you get zero, and a carry, which is 10. in two digits.

** Operationally, with bits, recpping earlier posts ...

If you want two's complements, add one to all n bits, and add one to the result.

Last edited by Lloyd Burns : 07-12-2002 at 10:09.