Integer & Base Converter
Convert hex, decimal and binary at 8, 16 or 32 bits: signed (two's complement), BCD, Gray code and Modbus register byte orders (ABCD, CDAB…).
Two's complement — when a negative number shows as 65535
- A register holds 16 bits, 0–65535. A device sending a negative number sets the top bit; read as «signed 16-bit» it becomes value − 65536.
- For example FFFF = 65535 = −1 and FE0C = 65036 = −500. Check whether the manual's data type is INT16 (signed) or UINT16 (unsigned).
- 32-bit values work the same way: value − 4294967296. Which register comes first is shown in the byte order table.
BCD — hex that reads like decimal
- BCD stores each decimal digit in 4 bits (0–9). 1234 becomes 0x1234, which reads as 4660 in decimal. Clock and counter values and some PLC instructions use BCD.
- Any nibble from A to F means it is not BCD. 16 bits hold 0–9999, 32 bits hold 0–99999999.
Gray code
A code where neighbouring values differ in one bit (g = b XOR (b ≫ 1)). 0–7 are 000, 001, 011, 010, 110, 111, 101, 100. Absolute encoders use it as an output format; if the encoder manual says Gray code output, use the «Gray code → binary» value as the position.
Reading the byte order table
«Sent as» shows the bytes when this value is sent in that order. A is the most significant byte. Within one Modbus register the high byte comes first (specification §4.2), but the order of two registers in a 32-bit value is up to the device. Enter the received bytes as hex and find the row in «if they arrived in this order» that matches the manual's example — that is the device's order.
FAQ
What is hex FFFF in decimal?
65535 as unsigned 16-bit, −1 as signed 16-bit (two's complement). It depends on the device's data type.
How do I convert a negative number to hex?
Set the input format to «Decimal» and type e.g. −500; you get the two's complement hex for the chosen width (FE0C at 16 bits).
How is BCD different from hex?
Hex writes the value in base 16; BCD stores each decimal digit in 4 bits. The value 1234 is 04D2 in hex and 1234 (0x1234) in BCD.
What about floats?
For 32- and 64-bit IEEE 754 values, the Modbus Float Converter shows all four byte orders.
To read two or four registers as float32 or float64, use the Modbus Float Converter.