Float and word order converter
Enter two registers as read from a device, and compare all four byte and word orders. Or enter a number to see the registers a device would send.
| Order | float32 | uint32 | int32 |
|---|---|---|---|
| ABCD | 123.456 | 1123477881 | 1123477881 |
| CDAB | -1.88337e+25 | 3917038326 | -377928970 |
| BADC | -9.86112e+32 | 4131551721 | -163415575 |
| DCBA | 1.51850e+35 | 2045376066 | 2045376066 |
| Order | Registers (hex) | Registers (decimal) |
|---|---|---|
| ABCD | 42F6 E979 | 17142 59769 |
| CDAB | E979 42F6 | 59769 17142 |
| BADC | F642 79E9 | 63042 31209 |
| DCBA | 79E9 F642 | 31209 63042 |
Runs in your browser. The values you type stay on your device.
Worked example: 123.456 in four orders
As an IEEE 754 float, 123.456 is the four bytes 42 F6 E9 79. A device can put those bytes
into two registers in four common ways, and the table above shows each one. Read 42F6 E979 as CDAB and
you get -1.88337e+25 instead of 123.456.
Reading 32-bit floats over Modbus explains how to find the right order on a device you don't have a manual for.
Questions
What does CDAB mean in Modbus?
It names the byte order of a 32-bit value spread over two registers. A and B are the two most significant bytes. In CDAB the register holding the low bytes comes first, a layout often called word swap.
Why does my float read as a huge number or a tiny one?
The device and your software disagree about word order. Decoded as CDAB, the registers of 123.456 turn into -1.88e+25. Try all four orders with the same two registers and pick the one that gives a sane value.
Is there a standard word order?
No. The Modbus specification defines 16-bit big-endian registers and says nothing about how to combine them into 32-bit values, so each vendor picks. Check the device manual, then confirm with a value you know.