1s-complement for sign integer conversion to binary

Conversion

positive value - no change E.g. 00001100

negative value, X - 2^n - X - 1 E.g. -00001100 Under 8-bit 1s-complement: 2^8 - 12 - 1 = 243 = 11110011

Invert the bits to get the complement

Properties

If MSB is 1, it is negative

Full 0s and 1s are positive and negative 0s respectively: 0000 = +0 1111 = -0

Operations

Binary addition

  1. Binary add 2 numbers

  2. If there is carry out of MSB, it is said to be wrapped around That bit gets added to the LSB instead of in-front: 1 0111 becomes 0111 + 0001 = 1000

  3. Check for bit overflows.

Binary subtraction

  1. Take 1s-complement of B
  2. Binary addition: complement B + A