Two's Complement Converter (8–64 bit)
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
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.
Bitwise Calculator
AND, OR, XOR, NOT and bit shifts on two integers — shown in binary, hex, unsigned and signed decimal, with selectable 8, 16, 32 or 64-bit width.
MAC to EUI-64 / Link-local
Convert any MAC address into its modified EUI-64 interface ID and the matching IPv6 link-local address — the same form Windows / Linux compute automatically.
CRC-32 Calculator (CRC-32 & CRC-32C)
Compute the CRC-32 (IEEE 802.3, used by zip/gzip/PNG) or CRC-32C (Castagnoli) checksum of text or hex bytes, shown in lowercase hex, uppercase hex, and unsigned decimal — in your browser.
Aspect Ratio Calculator
Convert between width × height and aspect ratio (16:9, 4:3, 21:9, …) — fit any ratio inside a container.
Decimal ↔ Fraction Converter (with Inch-Fraction Table)
Convert any decimal into its closest fraction (with adjustable maximum denominator, including binary fractions for inch measurements), and any fraction back into decimal / percent. Includes side-by-side common-fraction and 1/16″ inch-fraction reference tables.