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
Binary add 2 numbers
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
Check for bit overflows.
Binary subtraction
- Take 1s-complement of B
- Binary addition: complement B + A