8 / 16 / 32 / 64 / 128-Bit • Signed & Unsigned
Two's Complement Calculator (Hex to Signed & Unsigned Integer)
Interpret fixed-width hexadecimal bit patterns as unsigned integers and signed two's complement integers, inspect one's complement and endianness, or encode signed decimals into fixed-width hex.
Signed Two's Complement Integer
-1
Unsigned Integer
255
Signed (Two's Complement)
-1
Fixed-Width Hex
0xFF
Most Significant Bit (Sign)
1
One's Complement (~x)
0x00
Two's Complement Negation (-x)
0x01
Big-Endian Bytes
FF
Little-Endian Bytes
FF
Fixed-Width Binary Representation
1111 1111
Why the Same Hexadecimal Pattern Has Two Values
Computer memory only stores bits—it does not label whether a byte is signed or unsigned. In 8-bit arithmetic, the bit pattern FF (1111 1111₂) represents 255 as an unsigned byte (uint8_t) and −1 as a signed two's complement integer (int8_t). In 16-bit arithmetic, however, 00FF has a sign bit of 0, so it equals +255 in both signed and unsigned interpretations! That is why an explicit bit width is mandatory before treating hex as negative.
Signed & Unsigned Ranges by Bit Width
| Bit Width | Unsigned Range | Signed Two's Complement Range | Hex for −1 |
|---|---|---|---|
| 8-bit | 0 to 255 | -128 to +127 | 0xFF |
| 16-bit | 0 to 65,535 | -32,768 to +32,767 | 0xFFFF |
| 32-bit | 0 to 4,294,967,295 | -2,147,483,648 to +2,147,483,647 | 0xFFFFFFFF |
| 64-bit | 0 to 18,446,744,073,709,551,615 | -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 | 0xFFFFFFFFFFFFFFFF |