Updated · Built and checked by the PlinzoTools team, formulas tested against published sources
Compute the 1's and 2's complement of a decimal or binary number at any bit width.
The MSB of the 2's complement result is 1, confirming this is a negative number. -5 is stored as 1111 1011 in 8-bit two's complement form.
Two's complement is the standard way modern computers represent negative integers in binary -- it's what lets a fixed-width binary number encode both positive and negative values without a separate "sign bit" scheme causing ambiguity (like two different representations of zero). This calculator computes a number's binary form, its 1's complement (every bit flipped), and its 2's complement (1's complement plus 1) at your chosen bit width.
Enter either a decimal integer (like -42) or a binary string (like 1010) -- the tool auto-detects which format you've entered. Choose a bit width: Auto (calculated to fit your number), or a fixed 4, 8, 16, or 32 bits.
1's Complement = every bit of the binary representation flipped (0→1, 1→0)
2's Complement = 1's Complement + 1 (in binary, with overflow wrapped within the bit width)
Both the 1's and 2's complement are computed from the binary representation of the number's absolute value. This means for a positive input, the resulting "2's complement" shown is actually the encoding of that number's negative -- the calculator is answering "what would negating this number look like in binary," consistently whether you start from a positive or negative number.
| Bit Width | Signed Range |
|---|---|
| 4-bit | -8 to 7 |
| 8-bit | -128 to 127 |
| 16-bit | -32,768 to 32,767 |
| 32-bit | -2,147,483,648 to 2,147,483,647 |
Computer science students learning how signed integers are actually stored in memory. Programmers debugging low-level bitwise operations, embedded systems work, or interpreting a raw memory/register dump that uses signed binary values.
If you enter a decimal number that doesn't fit within your selected bit width's signed range (for example, 200 at 8-bit width, which only supports up to 127), the calculator will flag that the value exceeds what that bit width can represent -- widen the bit width or reduce the number.
The page's example starts from a positive number, but many people arrive with a negative decimal such as -42 and want to see how it looks in memory. Enter -42 with an 8-bit width. The absolute value 42 is 00101010 in binary. Flipping every bit gives the 1's complement, 11010101. Adding 1 gives the 2's complement, 11010110. That final pattern is exactly how most computers store -42 in a signed byte. You can check it by reading it back: the leading bit is 1, so the value is negative, and inverting then adding 1 again returns 00101010, which is 42.
A smaller case shows the same idea at 4 bits. Take 7, which is 0111. The 1's complement is 1000 and the 2's complement is 1001, the 4-bit encoding of -7. Notice that 1000 on its own, without the extra +1, would be -8 in 4-bit signed form. That is why the range table is lopsided, with one more negative value than positive.
Beyond coursework, this calculation shows up when reading assembly output, checking overflow behavior in C or embedded code, interpreting sensor values sent as signed bytes, and verifying what a bitwise NOT plus one does in your own code. Use the tool to confirm a hand calculation before you commit it to a test case or an exam answer.
Two's complement avoids the "two zeros" problem a simple sign-bit scheme has (a separate +0 and -0), and it lets addition/subtraction circuits work identically for positive and negative numbers without special-case logic.
Match it to what you're actually working with -- 8-bit for a single byte, 16 or 32-bit for common integer sizes in most programming languages, or leave it on Auto to let the calculator size it to your specific number.
Yes -- the calculator auto-detects whether your input is a decimal integer or a binary string (containing only 0s and 1s).
If the leftmost bit is 1, invert all bits, add 1, and read the result as a positive number, then put a minus sign in front. For 11010110 that gives 00101010, which is 42, so the value is -42.
The value is the same, but the number of leading sign bits changes. A negative number is padded with 1s on the left when the width grows, and a positive number is padded with 0s.
Yes. Flipping 00000000 gives 11111111, and adding 1 overflows and wraps back to 00000000 within the bit width, which is why there is only one zero in this system.
Reference: NIST Weights and Measures