EN
My tools

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.

Used when Bit width is Custom.
Binary (two's complement)
1101 0110
Hex
0xD6
Octal
0o326
Signed value
-42
Unsigned value
214
Fits in 8 bits
Yes
One's complement encoding
1101 0101
of the signed value
Sign-magnitude encoding
1010 1010
of the signed value
Bitwise NOT (~x)
0x29 = 41
Negation (−x)
0x2A = 42
Ranges by width
WidthCommon typesSigned minSigned maxUnsigned max
8-bitint8_t / uint8_t · sbyte / byte-128127255
16-bitint16_t / uint16_t · short / ushort-327683276765535
32-bitint32_t / uint32_t · int / uint-214748364821474836474294967295
64-bitint64_t / uint64_t · long / ulong-9223372036854775808922337203685477580718446744073709551615
128-bitInt128 / UInt128 (.NET 7+), __int128-170141183460469231731687303715884105728170141183460469231731687303715884105727340282366920938463463374607431768211455
The same value at other widths
WidthFits?Two's complement (hex)
8-bityes0xD6
16-bityes0xFFD6
32-bityes0xFFFFFFD6
64-bityes0xFFFFFFFFFFFFFFD6
My tools →
Advertisement

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

  1. Type a number: a decimal like -42, or a hex/binary/octal bit pattern.
  2. Say how it is written.
  3. Choose the bit width — 8 for a byte, 32 for an int, 64 for a long, or a custom width.
  4. 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:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). Two's Complement Calculator (Signed / Unsigned Converter). https://kakao.mobile/tools/signed-unsigned-converter/

MLA

“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

Advertisement