Two's Complement Simulator
Convert between denary and two's complement binary, with the invert-and-add-one steps and the negative place value shown.
Denary → two's complement
With 8 bits you can store -128 to 127.
Two's complement → denary
Click bits to change them. The leftmost bit has a negative place value.
-128 + 64 + 16 + 2 + 1 = -45
Why two's complement?
- There is only one zero (00000000), unlike sign and magnitude.
- Subtraction becomes addition: A − B = A + (−B), so the CPU needs only an adder.
- Negate any number by inverting the bits and adding 1.
About This Simulation
This two's complement simulator converts between denary and signed binary. It shows the invert-and-add-one method for negative numbers and lets you click bits to see how the negative place value of the leftmost bit gives the signed value.
Features
- Any width from 1 to 16 bits, with its range
- Denary to two's complement: binary, one's complement, then add 1
- Clickable bits with place values, including the negative MSB
- The same bits read as signed and unsigned
- Smallest and largest values for each width
Topics covered
- Two's Complement
- Signed Binary
- Sign Bit
- Negative Numbers
- Range of Values
Explanation
Two's complement is the standard way computers store negative integers. The leftmost bit (the most significant bit) has a negative place value, for example −128 in 8 bits, while the other bits are positive as usual. A leading 1 therefore means the number is negative.
How it works
- For a positive number, write it in normal binary with a leading 0.
- For a negative number, write the positive version in binary, invert every bit (0 ↔ 1), then add 1.
- Shortcut: copy the bits from the right up to and including the first 1, then invert all the remaining bits.
- To convert back, add up the place values of the 1 bits, remembering the leftmost one is negative.
- With n bits the range is −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1, so 8 bits store −128 to 127.
Why it matters
Two's complement is on the IGCSE and AS Level syllabuses. It lets the CPU subtract by adding a negative number, so the same adder circuit handles both operations, and it has only one representation of zero.
Frequently Asked Questions
How do you convert −45 to 8-bit two's complement?
+45 = 00101101. Invert: 11010010. Add 1: 11010011.
Why is two's complement used instead of sign and magnitude?
It has only one zero, and addition works the same for positive and negative numbers, so subtraction can be done by adding the two's complement.
What is the range of an 8-bit two's complement number?
−128 (10000000) to +127 (01111111).
How can you tell if a two's complement number is negative?
Its leftmost (most significant) bit is 1.
Related Simulations
Number Systems
Bitwise Operations Simulator
Apply AND, OR, XOR, NOT, logical and arithmetic shifts and rotations to 8-bit values, and use masks to set, clear and test bits.
Number Systems
Floating Point Representation Simulator
Store numbers as a two's complement mantissa and exponent, normalise them and see rounding errors, plus IEEE 754 32-bit and 64-bit.
Number Systems
Number System Converter
Convert between binary, decimal, hex, octal
Number Systems
BCD Representation Simulator
Store each denary digit as a 4-bit nibble, compare BCD with pure binary and add BCD numbers with the +6 correction.

