Operations onSigned Integers
Negating signed binary, octal, hex
- invert all the bits: 1 => 0, 0 => 1(same as subtracting from -1)
- then add 1
- i.e. -N = ((-1) - N) + 1
- e.g. to negate C0F6 (negative):
= ((-1) - C0F6) + 1
= (FFFF - C0F6) + 1
= 3F09 + 1
= 3F0A (positive)
Converting negative decimal numbers
- convert the positive equivalent
- then negate it (using the above method)
- e.g. to convert decimal -16,138
= -(16,138) - make positive
= -(3F0A) - convert
= C0F6 - negate