Skip to content
๐Ÿงฎ Binary Complement Arithmetic

๐Ÿงฎ Binary Complement Arithmetic

This module explores how 1โ€™s complement and 2โ€™s complement systems handle addition, subtraction, and multiplication in binary. These systems allow negative numbers to be encoded and manipulated using only addition and bitwise logic.


๐Ÿ“Œ 1. Complement Basics

TypeDefinitionOperation
1โ€™s ComplementFlip all bits~A (bitwise NOT)
2โ€™s ComplementFlip all bits, then add 1~A + 1

โž• 2. Addition in Complement Systems

โœ… 2โ€™s Complement Addition

  A =  0101   (5)
  B =  1110   (-2 in 2's complement)
------------------
A + B =  0011   (3)
  • No special handling needed.
  • Overflow is ignored unless sign bit flips unexpectedly.

โœ… 1โ€™s Complement Addition (with end-around carry)

  A =  0101   (5)
  B =  1101   (-2 in 1's complement)
------------------
Sum =  10010  โ†’ drop overflow bit โ†’ 0010
Add carry: 0010 + 1 = 0011 (3)

Overflow is ignored because we specifically designed complements to ignore overflow, it is by design, check Derivation of Complement Forms to understand why it was designed like so

โž– 3. Subtraction via Complement Addition

โœ… 2โ€™s Complement Subtraction

To compute A - B, do A + (2โ€™s complement of B):

  A =  0101   (5)
  B =  0011   (3)
  ~B + 1 = 1100 + 1 = 1101 (-3)
------------------
A - B = 0101 + 1101 = 10010 โ†’ drop overflow โ†’ 0010 (2)

โœ… 1โ€™s Complement Subtraction

Use A + (1โ€™s complement of B) + 1, then apply end-around carry:

  A =  0101   (5)
  B =  0011   (3)
  ~B = 1100
------------------
Sum = 0101 + 1100 + 1 = 10010 โ†’ drop overflow โ†’ 0010
Add carry: 0010 + 1 = 0011 (2)

โœ–๏ธ 4. Multiplication in Complement Systems

Multiplication is typically done using unsigned logic, then sign is handled separately.

โœ… Example: 2โ€™s Complement Multiplication

  A =  1110   (-2)
  B =  0011   (3)
------------------
Unsigned: 2 ร— 3 = 6
Sign: Negative ร— Positive = Negative
Result: 11111010 (โˆ’6 in 8-bit 2โ€™s complement)

โš ๏ธ Notes

  • Multiplication requires sign extension.
  • Most systems use Boothโ€™s algorithm or signed multiplication logic.

๐Ÿงฉ Summary Table

Operation1โ€™s Complement2โ€™s Complement
AdditionAdd + end-around carryAdd directly
SubtractionAdd 1โ€™s complement + 1 + carryAdd 2โ€™s complement
MultiplicationUnsigned ร— Unsigned, then apply signSame, with sign logic
Last updated on