Two's Complement Calculator
Convert signed decimal numbers to two's complement binary, decode two's complement binary back to decimal, find 1's/2's complement steps, and check signed overflow.
๐ข Field Rule: In n-bit two's complement, the leftmost bit is the sign bit. Range is -2^(n-1) to 2^(n-1)-1. Use this with the Binary Converter, Gray Code Converter, Truth Table Generator and K-Map Solver.
โ Signed Decimal โ Two's Complement Binary
Signed Decimal Number
Bit Width
Output Grouping
Use this when you need the signed binary representation of a decimal number inside a fixed-width register.
Examples:
Two's Complement Binary
Interpret As
Input Cleanup
Paste a signed binary value. The calculator uses the leftmost bit as the sign bit.
Examples:
Positive Binary / Magnitude
Pad Bit Width
This tab shows the classic method: write the positive binary magnitude, invert all bits, then add 1.
Examples:
A Decimal
Operation
B Decimal
Bit Width
Signed overflow happens when the mathematical result is outside the selected two's complement range.
Examples:
๐ Formula Reference
Signed Range
n-bit range = -2^(n-1) to 2^(n-1)-1
Negative Encoding
two's complement = 2^n + negative value
Manual Method
2's complement = invert bits + 1
Decode Sign Bit
if MSB = 1: signed value = unsigned - 2^n
๐ Quick Reference
8-bit Range
Minimum-128
Maximum+127
-111111111
Common Values
-511111011
-1011110110
+1000001010
Bit Widths
4-bit-8 to 7
8-bit-128 to 127
16-bit-32768 to 32767
๐ Digital Logic Notes
MSB is the sign bitIn two's complement, a leftmost 0 means non-negative and a leftmost 1 means negative.
One zero onlyUnlike sign-magnitude and one's complement, two's complement has only one representation of zero.
Addition is hardware-friendlyTwo's complement lets digital circuits add positive and negative numbers using the same binary adder.
Overflow depends on bit widthThe same binary pattern can mean different values if interpreted as 4-bit, 8-bit or 16-bit signed data.
What is a Two's Complement Calculator?
A two's complement calculator converts signed decimal numbers into fixed-width binary form and converts two's complement binary back into decimal. It is useful for digital electronics, computer architecture, embedded systems and microcontroller programming.
How to calculate two's complement
To represent a negative number, write the positive magnitude in binary, invert every bit to get the one's complement, then add 1. For example, +5 is 00000101 in 8-bit binary. Invert it to 11111010 and add 1 to get 11111011, which represents -5.
Why computers use two's complement
Computers use two's complement because the same binary adder can handle addition and subtraction. It also avoids the double-zero problem found in sign-magnitude and one's complement systems.
โ Frequently Asked Questions
Invert all bits, then add 1. For example, 00000101 becomes 11111010 after inversion, then 11111011 after adding 1.
+5 is 00000101. The two's complement representation of -5 is 11111011.
8-bit two's complement ranges from -128 to +127.
If the sign bit is 0, read it as normal binary. If the sign bit is 1, subtract 2^n from the unsigned value, where n is the number of bits.
One's complement only inverts the bits. Two's complement inverts the bits and adds 1. Two's complement is more common because it has only one zero and simplifies arithmetic.
For addition, overflow happens when two numbers with the same sign produce a result with the opposite sign, or when the true mathematical result is outside the selected bit-width range.
The unsigned value of 10000000 is 128. Since the sign bit is 1, subtract 2^8 = 256. So 128 - 256 = -128.