Two's Complement Calculator (Signed / Unsigned Converter)
Convert integers to and from two's complement binary and hex at 8, 16, 32, 64 or any bit width, with signed/unsigned values, overflow and ranges.
| Width | Common types | Signed min | Signed max | Unsigned max |
|---|---|---|---|---|
| 8-bit | int8_t / uint8_t · sbyte / byte | -128 | 127 | 255 |
| 16-bit | int16_t / uint16_t · short / ushort | -32768 | 32767 | 65535 |
| 32-bit | int32_t / uint32_t · int / uint | -2147483648 | 2147483647 | 4294967295 |
| 64-bit | int64_t / uint64_t · long / ulong | -9223372036854775808 | 9223372036854775807 | 18446744073709551615 |
| 128-bit | Int128 / UInt128 (.NET 7+), __int128 | -170141183460469231731687303715884105728 | 170141183460469231731687303715884105727 | 340282366920938463463374607431768211455 |
| Width | Fits? | Two's complement (hex) |
|---|---|---|
| 8-bit | yes | 0xD6 |
| 16-bit | yes | 0xFFD6 |
| 32-bit | yes | 0xFFFFFFD6 |
| 64-bit | yes | 0xFFFFFFFFFFFFFFD6 |
Computers store negative integers in two's complement: the same bits can mean −1 in a signed byte or 255 in an unsigned one. This converter shows both readings of a bit pattern at 8, 16, 32, 64, 128 or any custom width, with the binary, hex and octal forms, whether the value fits or wraps around, and the older one's complement and sign-magnitude encodings for comparison. All arithmetic uses exact big integers, so 64- and 128-bit values are never rounded.
How to use this tool
- Type a number: a decimal like -42, or a hex/binary/octal bit pattern.
- Say how it is written.
- Choose the bit width — 8 for a byte, 32 for an int, 64 for a long, or a custom width.
- Read the signed and unsigned values, the bit pattern and the overflow check.
Formula
pattern = x mod 2ⁿ · signed = pattern − 2ⁿ if pattern ≥ 2ⁿ⁻¹, else pattern
n is the bit width. A negative x becomes 2ⁿ − |x|, which is the same as inverting the bits of |x| and adding 1. Signed n-bit values run from −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1, unsigned from 0 to 2ⁿ − 1. A decimal outside both ranges keeps only its lowest n bits — the same wrap-around a C or Java cast performs.
Example
For −42 in 8 bits: 256 − 42 = 214, so the pattern is 1101 0110 = 0xD6, which an unsigned byte reads as 214. One's complement would be 1101 0101 and sign-magnitude 1010 1010. At 16 bits the same value is 0xFFD6, at 32 bits 0xFFFFFFD6.
Frequently asked questions
Why is the range one larger on the negative side?
Zero takes one of the non-negative patterns, so an 8-bit signed byte holds −128 to 127. −128 has no positive partner: negating it overflows back to −128.
How do I negate a number in two's complement by hand?
Invert every bit and add 1. 5 is 0000 0101; inverted 1111 1010; plus 1 gives 1111 1011, which is −5.
What happens on overflow?
Hardware keeps the lowest n bits. 300 in an unsigned byte becomes 300 − 256 = 44. In C, signed overflow is undefined behaviour, so compilers may not wrap; Java and C# (unchecked) do wrap.
Where are one's complement and sign-magnitude used?
Rarely for integers today. Sign-magnitude survives in floating-point sign bits; one's complement in the Internet checksum (RFC 1071).
Last updated:
Page address with these inputs: https://kakao.mobile/tools/signed-unsigned-converter/
Cite or embed this tool
kakaoCalc. (2026, November 8). Two's Complement Calculator (Signed / Unsigned Converter). https://kakao.mobile/tools/signed-unsigned-converter/
“Two's Complement Calculator (Signed / Unsigned Converter).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/signed-unsigned-converter/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms