Two’s-Complement Subtraction
Two’s-complement subtraction is a standard way to subtract signed binary numbers. The main idea is to turn subtraction into addition, which is easier to perform in binary.
Method
- Keep the fixed bit width. Use the same number of bits for every number in the problem.
- Find the two’s complement of the number being subtracted.
- Invert every bit.
- Add 1 to the inverted number.
- Add the result to the first number. Perform ordinary binary addition.
- Discard any carry beyond the fixed width. In two’s-complement arithmetic, only the chosen number of bits is kept.
- Read the final answer. If the leftmost bit is 1, the result is negative; if it is 0, the result is nonnegative.
Check your work
A good check is to convert the binary result back to a signed value and see whether it matches the expected subtraction in decimal. Also, make sure you did not change the bit width or forget to drop the extra carry.
Common mistakes
- Forgetting to add 1 after inverting bits.
- Using a different bit width for the two numbers.
- Keeping the overflow carry instead of discarding it.
- Misreading the sign bit at the end.
With practice, the process becomes: complement, add, discard carry, then interpret the sign.