IEEE 754 and FLOAT32 (REAL)
How a 32-bit floating-point number is built — sign, exponent, mantissa, precision, NaN and infinity — and what it means for PLCs and Modbus.
Format
In IEC 61131-3, REAL is a 32-bit IEEE 754 number (binary32) and LREAL a 64-bit one (binary64). Device documentation calls them FLOAT32/FLOAT and FLOAT64/DOUBLE.
| Field | binary32 | binary64 |
|---|---|---|
| Sign | 1 bit | 1 bit |
| Exponent | 8 bits, bias 127 | 11 bits, bias 1023 |
| Mantissa (fraction) | 23 bits | 52 bits |
For a normal number: value = (−1)^sign × 1.mantissa × 2^(exponent − bias). The leading 1 of the mantissa is not stored.
Example: 50.0
0x42480000 = 0 10000100 10010000000000000000000
sign = 0 (+)
exponent = 0x84 = 132 → 132 − 127 = 5
mantissa = 1.5625
value = 1.5625 × 2^5 = 50.0
More values: 1.0 = 3F800000, −2.5 = C0200000, 0.1 = 3DCCCCCD.
Precision
FLOAT32 has about 7 significant decimal digits. Consequences:
0.1is not exact: 0.100000001490116… is stored;- not all integers above 2²⁴ = 16,777,216 are representable: 16,777,217 becomes 16,777,216;
- small increments to a large number are lost: an energy counter in REAL incremented by 0.001 kWh "freezes" after a few tens of thousands;
- comparing REALs for exact equality (
=) is unreliable — use a tolerance.
For counters and totals use integer types (UDINT, ULINT) in the smallest unit, or LREAL.
Special values
| Exponent | Mantissa | Value |
|---|---|---|
| all zeros | 0 | ±0 |
| all zeros | ≠ 0 | subnormal (very small) number |
| all ones | 0 | ±infinity (7F800000, FF800000) |
| all ones | ≠ 0 | NaN, e.g. 7FC00000 |
NaN often appears after 0/0 or when reading uninitialised registers. Every comparison with NaN is false — check for it before using a value in control.
FLOAT32 over Modbus
One FLOAT32 occupies two 16-bit registers. The word order is not defined by the standard — see byte and word order. A wrong order shows up as absurd magnitudes such as 1.2e-38 or 4.6e+18 instead of the expected 50.0.
Tools
- IEEE 754 Converter — FLOAT32/FLOAT64 bit breakdown and assembly in all byte orders.
- Modbus Data Converter — registers → FLOAT32.
Connections
Open in Knowledge Graph →Loading the map…
Sources
Updated 2026-10-01