Modbus Float Shows the Wrong Value? Fix the Byte Order

You read a floating-point value from your device and get 2.40e-41 instead of 123.0. Or a negative number with 33 digits. The connection is fine, the registers respond — the value is just garbage. Nine times out of ten, this is a byte order problem, and it takes two minutes to diagnose once you know where to look.

Modbus registers are 16 bits wide, but a 32-bit float needs two registers. The Modbus specification never dictated which register comes first — so device vendors picked all four possible orders. Pick the wrong one in your software and the same raw bytes decode to a completely different number.

The Four Byte Orders, With Real Numbers

Take a concrete example. A device holds 123.0 in two consecutive registers. In hex, the raw register contents are 0x42F6 and 0x0000 (four bytes: 42 F6 00 00). Watch what each byte order makes of the identical raw bytes:

Byte order Byte sequence Decoded float Also called
ABCD 42 F6 00 00 123.0 ✓ Big-endian, standard
BADC F6 42 00 00 −9.84 × 10³² (garbage) Byte-swapped
CDAB 00 00 42 F6 2.40 × 10⁻⁴¹ (garbage) Word-swapped
DCBA 00 00 F6 42 8.83 × 10⁻⁴¹ (garbage) Little-endian, reversed

The values in the “garbage” rows are computed, not guessed — feed the byte sequences above into any IEEE-754 decoder and you will get exactly these numbers. The pattern is worth memorizing: a word-swapped device (CDAB/DCBA) gives you absurdly tiny values near zero, while a byte-swapped one (BADC) tends to give absurdly large ones. That signature tells you which direction to swap.

What the Vendors Say: The “Swapped Float” Rule

This is not a fringe problem — major vendors document it. Schneider Electric’s official FAQ on reading swapped floating-point values states the rule plainly: swapped floating-point registers are read the same as regular floating-point registers, except the most significant word and least significant word are switched. In their worked example, a device holding the known value 230.1 was read with the registers in the order they appeared, produced the wrong result, and swapping Register 1 and Register 2 gave the correct floating-point value (Schneider Electric FAQ FA401500).

That is the CDAB case in our table: the register order is flipped while the bytes inside each register stay put. It is the single most common variant you will meet in the field.

Diagnose It in QModMaster

QModMaster (free, open-source LGPLv3 Modbus master simulator from the upstream project) gives you everything you need to confirm a byte-order problem without leaving the app:

Step 1: Look at the Raw Hex

Use the View menu to switch the register display between Hex, Int, and Float. In Hex view you see the actual bytes the device sent — no interpretation. If Hex shows 42F6 0000 but Float shows garbage, your connection is healthy and the interpretation is wrong. That is a byte-order problem, full stop.

Step 2: The Register-Swap Test

Suspect CDAB/word-swap? Mentally (or on paper) exchange the two registers and re-read:

  • Registers read as [0x0000, 0x42F6] decode to garbage → swap to [0x42F6, 0x0000] → 123.0. Word-swap confirmed.
  • If swapping does not fix it, the device may use BADC or DCBA — try those permutations against the raw hex from Step 1.

Many Modbus client libraries and SCADA packages let you set the float byte order per device once you know it. QModMaster itself displays values with its built-in interpretation, so the practical workflow is: read raw hex in QModMaster, confirm the correct permutation here, then configure the matching byte order in your production software.

The Two Usual Suspects: Wrong Address or Wrong Byte Order?

When a reading is wrong, there are exactly two common causes — and they look different:

  • Wrong address / off-by-one: you get a plausible but wrong value (e.g. 124.7 instead of 123.0, or a value that changes when it should not). See our register address offset guide.
  • Wrong byte order: you get absurd values — near-zero like 2.4e-41, or astronomically large like −9.8e+32. That is this page.

Check the address first (it is the cheaper mistake to rule out), then the byte order. Together they cover nearly every “my Modbus reading is wrong” support ticket.

Related Guides

Want to truly understand Modbus — not just click through it?
Byte order, framing, function codes: a good protocol book pays for itself on the first commissioning job.

See Recommended Modbus Books

Similar Posts