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.

Fieldbinary32binary64
Sign1 bit1 bit
Exponent8 bits, bias 12711 bits, bias 1023
Mantissa (fraction)23 bits52 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.1 is 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

ExponentMantissaValue
all zeros0±0
all zeros≠ 0subnormal (very small) number
all ones0±infinity (7F800000, FF800000)
all ones≠ 0NaN, 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

Loading the map…

Sources

  1. IEEE 754-2019 Standard for Floating-Point Arithmetic — IEEE
  2. IEC 61131-3:2025 Programmable controllers — Part 3: Programming languages — IEC

Updated 2026-10-01