Two's Complement Calculator: Two Methods

Representing negative numbers using two's complement

5
"Flip and Add One" Method
Step 1: Positive Binary
Convert X to N-bit binary
Step 2: Flip All Bits (One's Complement)
Invert each bit: 0 becomes 1, 1 becomes 0
Step 3: Add 1
Add 1 to the one's complement with carry propagation
Two's Complement of -5
"2^N - X" Method (Modular Arithmetic)
Step 1: Calculate 2^N
The modulus for N-bit two's complement
Step 2: Subtract X
2^N - X gives the unsigned equivalent of -X
Step 3: Convert to Binary
Convert the result to N-bit binary
Two's Complement of -5