111001-0101011001007424-12A8617C2's complement0000 0101 (5)1111 1011 (-5)32 bit integer has a range from -2
31
to 2
31
– 1 (to represent 0)A – B => A + (-B)To convert a number to 2's complement1)write the complement of the #Example: 00100110 => 110110012) add 1 => 11011010Other way, start on right side, use same digits up to & including the first 1after the first 1, flip the rest of the bits00101010 => 110101100110 1101 =>10010011January 18, 2006 N-340 next week both days.Subtraction with 2's complements1)Convert quantity to be subtracted to 2's complement2)Add 2's complement to other number 3)If a carry out occurs, we ignore it and use same number of bits as are in arguments.Decimal:17 – 8 = 900010001 – 00001000Convert 8 to 2's complement – 11111000add that to 17
Add a Comment