Modbus float byte order

A 32-bit float spans two registers and vendors disagree about the order. ABCD, BADC, CDAB and DCBA, and how to identify which one a device uses.

6 min read · Updated

Modbus defines a 16-bit register and says nothing about how to spread a 32-bit value across two of them. Every vendor made a choice, and all four possible choices are in the field.

The four orders

Label the four bytes of a 32-bit value A, B, C and D, with A the most significant. The two registers can carry them in four ways:

NameRegister 1Register 2Also called
ABCDABCDBig-endian
CDABCDABBig-endian byte swap, word swap
BADCBADCLittle-endian byte swap
DCBADCBALittle-endian

ABCD and CDAB are by far the most common. They differ only in which register holds the high word, which is why swapping words is the first thing to try when a float reads as nonsense.

What a wrong order looks like

It does not throw an error. It produces a number, and the number is usually obviously wrong in one of a few ways:

  • Absurd magnitude — 1.7e38 or 3.4e-41 where you expected 230.5.
  • A value near zero that never changes, while the real value is large.
  • A number that moves when the process moves, but by the wrong amount and in a jumpy way.
230.5 as a 32-bit float, in each order
230.5  =  0x436C8000

ABCD   register 1 = 0x436C   register 2 = 0x8000   -> 230.5      correct
CDAB   register 1 = 0x8000   register 2 = 0x436C   -> 2.7e-40    wrong
BADC   register 1 = 0x6C43   register 2 = 0x0080   -> 9.5e26     wrong
DCBA   register 1 = 0x0080   register 2 = 0x6C43   -> 1.2e-38    wrong

Finding the right one without guessing blindly

The reliable method is to read a register pair whose true value you know or can estimate — a voltage near 230, a frequency near 50, a temperature near ambient — and reinterpret the same two registers in all four orders. Exactly one will be plausible.

The Modbus Polling Tool decodes the registers it has already read, so you can change the byte order and see all four interpretations without polling the device again. The Scanner uses the same idea in reverse: it looks at the values and suggests which order makes them plausible.

The same applies to 32-bit integers and 64-bit values

Word order affects any multi-register value, not just floats. A 32-bit energy counter read with swapped words increments in large irregular jumps instead of counting smoothly — a good diagnostic in itself. 64-bit values span four registers and the same principle applies across all four.

Byte order is a property of the device, not of the value. Once you have established it for one register pair, it applies to every multi-register value on that device — unless the vendor mixed conventions, which does happen.
Free tool

Modbus Polling Tool

Poll, inspect and troubleshoot Modbus devices in real time.

Modbus float byte order | Modbus Logic