Can either be represented with

  1. Sign-and-magnitude
    • There is a separate bit that determines the sign for the rest of the number
    • 1 = negative. = 0 positive.
    • For an 8-bit number, the range would be from
  2. Signed numbers (2’s complement)
    • For an -bit number, the term is negated. This is the Most significant bit (MSB)
      • For an bit number, the number is actually
    • Every other digit is positive

Represent -18 as a 6-bit number via Sign and magnitude + two's complement (signed)

For sign-and-magnitude, the sign would be 1 (it’s negative). The other 5 bits would be 10010

For 2’s complement, it would be 101110 100000 = -32 01110 = 14 -32 + 14 = -18, as required!

Shortcut to converting a binary number to two’s complement

Taking the 2’s complement of a number negates it!

Idea:

To get 1’s complement, you invert every bit Then you just add 1

Corollary:

So to be clear, the 2’s complement of is just

Shorter shortcut

Start going through each number from the right side. Once you hit a 1 from the right side, you keep that number and flip everything left of it.

Common negative values

For an -bit number:

  • -1 is always gonna be 111111...