Sign and Magnitude


One way to represent negative numbers is to make the left most bit the sign bit. The sign bit sets if the number is negative or not.

Example

00000011 = 3
10000011 = -3

Two's Complement

Two’s Complement


Two’s compliment allows us to convert numbers from positive to negative and vice versa.

Steps

  1. Flip all the bits.
  2. Add 1.

Example

00000011 = 3

FLIP 11111100
ADD  00000001
------------
     11111101 = -3
    
Link to original