Two's Complement Converter (8–64 bit)
Convert
Two's complement is how almost every computer stores signed integers: the top bit is the sign, and a negative number is formed by inverting the bits of its magnitude and adding one. This converter takes any integer — typed as decimal, hex (0x), binary (0b), or octal (0o), positive or negative — fits it into a chosen width of 8, 16, 32, or 64 bits, and shows the resulting bit pattern with the sign bit highlighted. From that one pattern it reads back both the signed (two's complement) value and the unsigned value, along with hex, octal, and the one's complement. It's the quick way to answer questions like "what does 0xFF mean as a signed byte?" (−1) or "how is −128 stored in 8 bits?" (0x80), and to see how values wrap when they overflow a width. Arbitrary-precision BigInt math keeps 64-bit values exact. Everything runs locally; nothing is uploaded.
Prefix with 0x for hex, 0b for binary, 0o for octal; otherwise decimal. A leading − is allowed.
1101 0110
Two's complement: top bit is the sign. The same pattern reads as one signed and one unsigned value.
How to use
- Type a value as decimal, or with a 0x / 0b / 0o prefix for hex, binary, or octal.
- Pick the bit width (8, 16, 32, or 64).
- Read the signed and unsigned values, the bit pattern, hex/octal, and one's complement; a note appears if the value didn't fit and wrapped.
Frequently asked questions
- How is a negative number represented?
- In two's complement, you take the binary of the absolute value, invert every bit (one's complement), then add one. For an 8-bit −5: 5 is 00000101, inverted is 11111010, plus one is 11111011 = 0xFB. The top bit being 1 marks it negative. This tool does that automatically for any width.
- Why does 0xFF show as both 255 and −1?
- The same bit pattern means different numbers depending on whether you read it as unsigned or signed. As an unsigned byte, 11111111 is 255; as a signed two's complement byte, it's −1. Hardware and languages pick one interpretation per type (e.g. uint8 vs int8); this tool shows both at once.
- What happens if my number doesn't fit the width?
- It wraps. A value outside the width's range is reduced modulo 2^width — the same thing fixed-width integer arithmetic does on overflow. For example 300 in 8 bits becomes 300 − 256 = 44, and the signed reading follows from that pattern. A note flags when wrapping occurred.
- What's one's complement versus two's complement?
- One's complement is just the bitwise NOT — every 0 becomes 1 and vice versa. Two's complement is one's complement plus one, and it's what modern CPUs use for signed integers because it has a single zero and makes addition uniform. The tool shows the one's complement as an extra reference.
Related tools
BCD Converter (Binary-Coded Decimal)
Convert decimal to and from 8421 binary-coded decimal — per-digit 4-bit nibbles, packed BCD hex bytes, and BCD validity checking.
Gray Code Converter
Convert between decimal, binary and reflected-binary Gray code, both directions, with an optional fixed bit width and a 0-7 reference table.
IEEE 754 Float Converter (32 & 64-bit)
See the exact IEEE 754 bit layout of any number in float32 and float64 — sign, exponent, and mantissa bits, hex, the stored value, and rounding — or decode hex bits back to a number, all in your browser.
Roman Numeral Converter
Convert between Arabic numbers and Roman numerals from 1 to 3999.
Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal.
Unit Converter
Convert length, weight, temperature, area, volume, speed, and time.