Reading 32-bit floats over Modbus: ABCD, CDAB, BADC and DCBA
· By Vladimir Chemeris, developer of Modbus TCP FieldKit
Short answer: Modbus registers are 16 bits, so a float32 takes two, and the protocol doesn’t say which goes first. Read a known value, try all four orders in the float converter, and save the one that matches.
Why this happens
The specification defines registers as 16-bit values sent big-endian, high byte first. It says nothing about combining two registers into one number, so each vendor chooses. Name the four bytes of an IEEE 754 float A B C D, with A most significant, and you get four layouts:
| Order | Registers hold | Common name |
|---|---|---|
ABCD |
AB, CD |
Big-endian |
CDAB |
CD, AB |
Word swap, little-endian word order |
BADC |
BA, DC |
Byte swap |
DCBA |
DC, BA |
Little-endian |
Real values
We loaded 123.456 into a pymodbus 3.16.1 server in two layouts. In IEEE 754, 123.456 is 42 F6 E9 79.
Stored as ABCD at address 10:
TX 00 01 00 00 00 06 01 03 00 0A 00 02
RX 00 01 00 00 00 07 01 03 04 42 F6 E9 79
Stored as CDAB at address 12:
TX 00 01 00 00 00 06 01 03 00 0C 00 02
RX 00 01 00 00 00 07 01 03 04 E9 79 42 F6
Decode the first response, 42F6 E979, under each order, and only one gives a sane answer:
| Read as | Result |
|---|---|
ABCD |
123.456 |
CDAB |
-1.88e+25 |
BADC |
-9.86e+32 |
DCBA |
1.52e+35 |
Swapping bytes moves mantissa bits into the exponent, so a wrong order tends to give a huge or tiny number. There is one exception: 0.0 reads as 0.0 in all four orders, so test with a non-zero value.
Finding the order on a device
- Pick a value you can check another way: a voltage on the display, a temperature, or a setpoint you control.
- Read two registers at its documented address. Mind the off-by-one: starting one register late produces garbage that no order can fix.
- Decode under all four orders.
- Change the value on the device and read again. The right order follows the change.
The same applies to 32-bit integers
A uint32 energy counter has the same problem. With a low value the high word is zero, so a swapped reading comes out as an exact multiple of 65536: a counter at 1000 reads as 65536000. If a meter’s total looks like that, suspect word order first.
For 64-bit values, the same idea extends to four registers, and vendors disagree there too.
Saving the answer
In FieldKit, each register definition in a profile stores format, byte and word order, scale and unit. Once you find the order, the Register browser shows 123.456 instead of two integers, and you keep that setting for the next device of the same model.
Sources
- Modbus Application Protocol Specification V1.1b3, section 4.2 (data encoding)
- Frames captured on 30 October 2026 from pymodbus 3.16.1 on Linux
FAQ
What is the most common Modbus float word order?
There's no standard. The specification defines 16-bit registers and leaves multi-register values to the vendor, so check the manual and confirm with a value you know. ABCD and CDAB are the two you will meet most often.
What does word swap mean?
The two 16-bit registers arrive in reverse order, but the bytes inside each register stay in place. In the letter notation that is CDAB.
How do I find the order without a manual?
Read two registers while the device shows a known value, such as a voltage on its display. Decode them under all four orders and pick the one that matches.