⚡ Signed-2's Complement Arithmetic

Understanding Binary Addition & Subtraction in Modern Computers

🎯 What is Signed-2's Complement?

The signed-2's complement system is the standard method for representing both positive and negative numbers in modern digital computers. It elegantly simplifies arithmetic operations by unifying addition and subtraction into a single hardware process.

Key Insight: The leftmost bit (sign bit) determines if the number is positive (0) or negative (1). For negative numbers, the entire representation is the 2's complement of the positive value.
Concept Description
Sign Bit Leftmost bit: 0 for positive, 1 for negative
Positive Numbers Sign bit = 0, magnitude in standard binary
Negative Numbers Sign bit = 1, value is 2's complement of magnitude

🧮 Interactive Calculator

Try signed-2's complement arithmetic yourself! Enter two decimal numbers and see the binary operations.

📊 Algorithm Flowcharts

Visual representation of the addition and subtraction processes, showing how both operations use the same hardware path.

Subtract

Minuend in AC Subtrahend in BR AC ← AC + BR' + 1 V ← overflow (2's complement + add) END

Add

Augend in AC Addend in BR AC ← AC + BR V ← overflow (direct addition) END
🎯 Key Observation: Both operations follow the same structure and use identical hardware! Subtraction is simply addition with a 2's complement preprocessing step. This unified approach is what makes signed-2's complement so elegant and efficient.

➕ Addition Algorithm Details

Addition is straightforward: simply add the two binary numbers including their sign bits.

AC ← AC + BR

➖ Subtraction Algorithm Details

Subtraction is cleverly transformed into addition by using the 2's complement of the subtrahend.

AC ← AC + BR' + 1
Why This Works: Taking the 2's complement of a number effectively negates it. So A - B becomes A + (-B), allowing us to use the same addition hardware!

⚠️ Overflow Detection

Overflow occurs when the result exceeds the capacity of the fixed number of bits. We detect this by examining the carries into and out of the sign bit position.

V = Cin ⊕ Cout
Detection Rule: Overflow occurs when the carry INTO the sign bit (Cin) is different from the carry OUT of the sign bit (Cout). This is detected using an XOR operation.

Examples of Overflow:

🔌 Hardware Architecture

The beauty of signed-2's complement is its simple hardware implementation using just a few key components.

Hardware Diagram: Below is the basic architecture showing how registers, adder, and complementer work together.
BR register Complementer and parallel adder AC register V Overflow
Component Role
AC Register Accumulator - holds operands and results
BR Register Buffer Register - holds the second operand
Complementer Inverts all bits for 2's complement operation
Parallel Adder Performs the binary addition
V Flip-Flop Overflow indicator flag
Efficiency Advantage: Both addition and subtraction use the same adder hardware, making the design simple and cost-effective. The output carry is ignored; overflow detection uses the internal carries instead.
Start Learning Multiplication Algorithm