Calculating 2's Compliment                                                                           


Binary Addition

Binary Subtraction


A Positive Number
is represented as a simple unsigned binary.
A Negative Number
is represented as the binary number that when added to a positive number of the same magnitude equals zero.
To form a negative number:

For example,

Positive Integer 4 0000 0100
Compliment of 4
+ 1
1111 1011
0000 0001
Negative Integer 4 1111 1100

Integer Two's Compliment
3 0000 0011
2 0000 0010
1 0000 0001
0 0000 0000
-1 1111 1111
-2 1111 1110
-3 1111 1101
Most Significant Bit (MSB) indicates the sign of the integer.
 
If MSB = 0, then the number is greater than or equal to 0. ( >=0)
 
If MSB = 1, then the number is less than 0. (<0)

2's Compliment Arithmetic

Addition        
5 + (-3):   0000 0101 (+5)
  + 1111 1101
(-3)
    0000 0010 (+2)

Subtraction
3 - 5:   0000 0011 (+3)
  + 1111 1011
(-5)
    1111 1110 (-2)

Notes

Rules of Binary Addition
  1. 0 + 0 = 0
  2. 0 + 1 = 1
  3. 1 + 0 = 1
  4. 1 + 1 = 0, and carry 1 to the next more significant bit
Rules of Binary Subtraction
  1. 0 - 0 = 0
  2. 0 - 1 = 1, and borrow 1 from the next more significant bit
  3. 1 - 0 = 1
  4. 1 - 1 = 0

Copyright © Escuela Campo Alegre, 2000-2001. All rights reserved
Website developed and maintained by Shashi Krishna, HS Computer Science.