Two's Complement Calculator
Convert signed decimals to two's complement binary and hex — and back — at 8, 16, 32 or 64 bits, with the invert-and-add-one steps shown. Free online tool.
Two's-complement binary
1111 1011
Invert-and-add-one working
| |value| in binary | 0000 0101 |
| invert every bit | 1111 1010 |
| add 1 | 1111 1011 |
What is the Two's Complement Calculator?
The ByteTools Two's Complement Calculator converts between signed decimal numbers and their two's-complement binary and hex representations at 8, 16, 32 or 64-bit widths.
- Both directions: decimal ↔ two's-complement binary/hex
- 8, 16, 32 and 64-bit widths with exact arithmetic
- Invert-and-add-one working shown for negative values
- Representable range displayed for every width
- Out-of-range input rejected with a clear explanation
- 100% client-side and instant
How to use the Two's Complement Calculator
- 1
Choose the direction: decimal → two's complement, or a binary/hex pattern → decimal.
- 2
Pick the bit width: 8, 16, 32 or 64 bits.
- 3
Enter the value or pattern.
- 4
Read the signed decimal, binary and hex forms, plus the range for that width.
- 5
For negatives, follow the invert-and-add-one working row by row.
About the Two's Complement Calculator
The ByteTools Two's Complement Calculator converts between signed decimal numbers and their two's-complement binary and hex representations at 8, 16, 32 or 64-bit widths. It works in both directions: give it -5 and get 11111011, or give it a bit pattern like 0xFB and get the signed value back.
For negative numbers the tool shows the textbook working — the absolute value in binary, every bit inverted, then 1 added — so you can follow exactly how the pattern is formed. It also displays the representable range for the chosen width and refuses out-of-range values with a clear message instead of silently wrapping.
All math uses exact arbitrary-precision arithmetic, including the full 64-bit width, and runs 100% locally in your browser with nothing uploaded or stored.
Frequently asked questions
What is two's complement?
Two's complement is how virtually all computers store signed integers. Positive numbers use their ordinary binary form; a negative number is stored as the pattern you get by inverting every bit of its absolute value and adding 1. It is popular because addition and subtraction then work identically for positive and negative values with no special cases.
How do I find the two's complement of -5 in 8 bits?
Start with +5 as 00000101, invert every bit to get 11111010, then add 1 to get 11111011, which is 0xFB. The calculator shows these exact three rows for any negative number you enter.
What range of numbers fits in each bit width?
An n-bit two's complement value spans -2ⁿ⁻¹ to 2ⁿ⁻¹-1. That is -128 to 127 for 8 bits, -32768 to 32767 for 16, -2147483648 to 2147483647 for 32, and about ±9.2 quintillion for 64 bits. The asymmetry exists because zero occupies one of the non-negative patterns.
How do I tell if a bit pattern represents a negative number?
Look at the most significant (leftmost) bit at the chosen width: 1 means negative, 0 means non-negative. The same pattern means different things at different widths — 0xFB is -5 as an 8-bit value but +251 as a 16-bit value, which is why the width selector matters.
Why does the calculator reject 200 at 8 bits instead of wrapping it?
Because silent wrap-around is the classic source of overflow bugs. 200 does not fit in signed 8-bit range (-128 to 127), so the tool tells you and suggests a wider width. If you actually want the wrapped interpretation, enter the pattern 11001000 in pattern mode and read the signed value -56.
Related tools
Bitwise Calculator
Calculate AND, OR, XOR, NOT and bit shifts on 32-bit values online. Enter operands in any base and see results in decimal, hex, octal and binary at once.
Decimal to Binary
Convert decimal to binary online with optional nibble grouping for readability. Handles very large numbers exactly with BigInt. Free, instant and private.
Binary to Decimal
Convert binary to decimal online. Validates that the input is only 0s and 1s and handles very long binary strings exactly with BigInt. Free and private.
IEEE 754 Floating Point Converter
Convert decimals to IEEE 754 single or double precision and back. See sign, exponent and mantissa bits, the exact stored value and the rounding error.
Decimal to Hex
Convert decimal to hexadecimal online with uppercase and 0x-prefix toggles. Handles very large numbers exactly using BigInt. Free, instant and private.