Two’s Complement Hex Converter
Convert a fixed-width hexadecimal two’s-complement value into its signed decimal interpretation. Select the bit width to decode negative hex values and view the corresponding binary bit pattern, unsigned value and signed range.
If MSB = 1: Signed Value = Unsigned Value – 2^N
What Is a Two’s Complement Hex Value?
Two’s complement is the most common representation for signed binary integers in modern digital systems. Because hexadecimal provides a compact representation of binary bits, signed machine values are frequently displayed as hexadecimal words such as FF, FFF6 or FFFFFFFF.
A hexadecimal value itself is simply a bit pattern. Whether it represents a positive or negative number depends on the selected word width and signed interpretation.
How the Two’s Complement Hex Converter Works
The converter first interprets the hexadecimal input as an unsigned binary value. It then checks the most-significant bit of the selected fixed-width word.
Sign bit = 1 → negative two’s-complement value
When the sign bit is one, the signed result is found by subtracting 2 raised to the selected bit width from the unsigned value.
Two’s Complement Hex Formula
For an N-bit hexadecimal word:
Signed = Unsigned
Otherwise:
Signed = Unsigned – 2^N
This provides a direct numerical conversion without manually flipping bits and adding one.
8-Bit Two’s Complement Hex Example
Consider hexadecimal F6 interpreted as an 8-bit signed integer.
Binary: 11110110
Unsigned Decimal: 246
The first binary bit is 1, so the value is negative.
= 246 – 256
= -10
16-Bit Two’s Complement Hex Example
Consider:
Width: 16-bit
The unsigned hexadecimal value is 65526.
= -10
The value therefore represents the same mathematical integer as 8-bit F6, but it uses a wider signed representation.
Why Bit Width Matters
Two’s-complement interpretation cannot be performed correctly without knowing the width of the signed word.
Hex 00FF as 16-bit: 255
The hexadecimal digits may appear related, but the position of the sign bit changes with word width.
Two’s Complement Signed Ranges
| Width | Minimum | Maximum | Negative Sign Starts At |
|---|---|---|---|
| 8-bit | -128 | 127 | 0x80 |
| 16-bit | -32,768 | 32,767 | 0x8000 |
| 24-bit | -8,388,608 | 8,388,607 | 0x800000 |
| 32-bit | -2,147,483,648 | 2,147,483,647 | 0x80000000 |
Hex FF as Two’s Complement
An 8-bit hexadecimal value FF corresponds to binary:
The unsigned value is 255, but as an 8-bit two’s-complement integer:
Therefore:
Hex 80 as Signed 8-Bit
Hexadecimal 80 is:
Its unsigned value is 128. As an 8-bit signed two’s-complement integer:
This is the minimum value representable by an 8-bit signed integer.
Hex 7F as Signed 8-Bit
Hexadecimal 7F converts to:
The sign bit is zero, so no subtraction is required.
This is the maximum signed 8-bit two’s-complement value.
Hex FFFFFFFF as Signed 32-Bit
A common value seen in registers, memory dumps and APIs is:
As an unsigned 32-bit number it equals 4,294,967,295. As a signed 32-bit two’s-complement integer:
Hex 80000000 as Signed 32-Bit
The most negative signed 32-bit two’s-complement value is:
Signed Decimal: -2,147,483,648
This asymmetry is a normal property of two’s complement: there is one more negative value than positive value.
Positive Two’s Complement Hex Values
Two’s-complement notation does not mean every hexadecimal value is negative. If the most-significant bit of the selected word is zero, the signed and unsigned decimal interpretations are identical.
8-bit Binary: 00100101
Unsigned: 37
Signed: 37
Two’s Complement Hex in Embedded Systems
Embedded processors frequently store signed integers in two’s-complement form. Debuggers and register viewers often display those underlying bits as hexadecimal, so a negative reading may appear as a large hexadecimal value instead of an obvious negative decimal number.
Converting the fixed-width hex representation is useful when inspecting firmware variables, hardware registers, memory maps and device communication data.
Two’s Complement Hex in Sensor Registers
Many accelerometers, temperature sensors, gyroscopes, magnetic sensors and measurement devices return signed integers using two’s complement. Their raw registers may be displayed as hexadecimal bytes or words.
16-bit signed interpretation: -10
Any sensor-specific scaling must be applied separately after decoding the signed integer.
Two’s Complement Hex in CAN and Modbus Data
Industrial and automotive data may contain fixed-width signed fields. After bytes are assembled in the correct byte order, the resulting hexadecimal word can require two’s-complement interpretation.
This converter assumes the hex word has already been assembled correctly. It does not change byte order or apply protocol-specific signal scaling.
Two’s Complement Hex vs Unsigned Hex
The underlying bits are identical; only their numerical interpretation changes.
| Hex | 8-Bit Unsigned | 8-Bit Signed |
|---|---|---|
| 00 | 0 | 0 |
| 01 | 1 | 1 |
| 7F | 127 | 127 |
| 80 | 128 | -128 |
| FE | 254 | -2 |
| FF | 255 | -1 |
Two’s Complement Hex Converter vs Binary Two’s Complement Tool
These tools begin from different user inputs and solve different practical tasks.
| Tool | Main Input | Purpose |
|---|---|---|
| Two’s Complement Hex Converter | Fixed-width hexadecimal word | Decode signed hexadecimal machine data |
| Binary Two’s Complement Tool | Binary value | Work directly with two’s-complement binary bits |
Why Leading Zeros Matter
Leading zeros can make the intended word width explicit.
00FF as 16-bit = 255
This calculator pads shorter inputs with leading zeros to the selected width but never allows a hexadecimal value that exceeds that width.
Important Two’s Complement Hex Notes
The calculator supports 8, 16, 24 and 32-bit values.
An optional 0x prefix is accepted.
Shorter hexadecimal input is padded with leading zeros to the selected width.
Input that exceeds the selected bit width is rejected rather than silently truncated.
If the most-significant bit is 0, signed value equals unsigned value.
If the most-significant bit is 1, signed value equals unsigned value minus 2^N.
This tool interprets an existing hexadecimal bit pattern. It does not change endianness, reorder bytes, apply sensor scaling or perform protocol decoding.
When decoding real registers or packets, confirm the correct field width and byte order from the relevant specification.