2026-09-08
Siemens PLCs support three floating-point data types: REAL (32-bit, IEEE 754 single precision), LREAL (64-bit, IEEE 754 double precision), and S5TIME (a special format for timer values, but not a true floating-point type for mathematical operations). The REAL type is the most commonly used floating-point format in Siemens PLC programming. It provides a range of approximately ±1.18×10⁻³⁸ to ±3.40×10³⁸ with a precision of about 7 decimal digits. The LREAL type is available on S7-1500 and S7-400 CPUs with firmware version 2.0 or higher, providing approximately 15 decimal digits of precision.
The table below compares the characteristics of these data types across Siemens PLC families.
| Data type | Bit length | Precision (decimal digits) | Supported CPU families | Instruction set availability |
| REAL | 32 | 6 – 7 | S7-300, S7-400, S7-1200, S7-1500 | Full math instruction set |
| LREAL | 64 | 15 – 16 | S7-400 (firmware 2.0+), S7-1500 | Limited to newer CPUs |
| S7_TIME | 32 | N/A (integer format) | All Siemens PLCs | Not applicable for math |
When programming a Siemens PLC, you must select the appropriate data type for your application. For most process control applications, REAL is sufficient. For applications that require high precision, such as coordinate calculation for CNC or precision metering, you may need LREAL. In our factory, we use REAL for most applications and LREAL only when the cumulative error of multiple REAL operations exceeds the tolerance. Yueyang Tongtu E-commerce Co., Ltd. supplies Siemens PLC units with both REAL and LREAL support, and we provide guidance on selecting the right CPU based on your precision requirements.
Siemens PLCs provide a comprehensive set of floating-point instructions in both LAD (ladder diagram) and STL (statement list) programming languages. The core instructions include: ADD (addition), SUB (subtraction), MUL (multiplication), DIV (division), and SQRT (square root). The instructions operate on REAL and LREAL data types. The table below lists the instructions, their syntax, and the CPU cycle time for each operation.
| Operation | LAD instruction | STL instruction | Execution time (S7-1500) | Execution time (S7-1200) |
| Addition (REAL) | ADD | +R | ~0.05 µs | ~0.15 µs |
| Subtraction (REAL) | SUB | -R | ~0.05 µs | ~0.15 µs |
| Multiplication (REAL) | MUL | *R | ~0.05 µs | ~0.15 µs |
| Division (REAL) | DIV | /R | ~0.08 µs | ~0.20 µs |
| Square root (REAL) | SQRT | SQRT | ~0.12 µs | ~0.35 µs |
| Square root (LREAL) | SQRT (with LREAL tag) | SQRT | ~0.25 µs | Not supported |
The SQRT instruction expects the input value to be a non-negative REAL or LREAL number. If a negative value is provided, the instruction will return an undefined result (typically a NaN or a negative number, depending on the CPU firmware). In our factory, we always check the input value before calling SQRT to ensure it is non-negative. We also handle the case where the input is zero, which returns zero.
Floating-point operations in Siemens PLCs follow the IEEE 754 standard. This means that not all numbers can be represented exactly, and the result of a sequence of operations may accumulate rounding errors. For example, the number 0.1 cannot be represented exactly in binary floating-point. When you add 0.1 ten times, the result may be 0.99999999 instead of 1.0. This is not a bug; it is a fundamental limitation of floating-point representation. To manage this, you should round the result to the required precision using the ROUND or TRUNC instructions. In our factory, we recommend using a tolerance of 1e-6 when comparing floating-point values in Siemens PLC programs.
The square root operation is also subject to precision limitations. The SQRT instruction uses an iterative algorithm that provides a result accurate to the last bit of the mantissa. For most applications, this is sufficient. For high precision applications, such as flow measurement with differential pressure transmitters, we recommend using the SQRT instruction with REAL data and then converting the result to a scaled integer value for display.
The performance of floating-point operations varies significantly between Siemens PLC families. The S7-1500 family has a dedicated floating-point unit (FPU) that executes floating-point instructions in hardware. The S7-1200 family also has hardware floating-point support, but the execution time is slightly longer. The S7-300 family (especially older models) executes floating-point instructions in software, which can take 10 to 20 times longer. The S7-400 family has a high-performance FPU and supports both REAL and LREAL operations. When selecting a Siemens PLC for an application that requires extensive floating-point calculations, the choice of CPU is critical. In our factory, we recommend the S7-1500 for applications that involve more than 100 floating-point operations per scan cycle.
Siemens PLCs provide comprehensive support for floating-point and square root operations through the REAL and LREAL data types and a complete set of math instructions. The performance and precision depend on the CPU family, the data type, and the programming language used. The S7-1500 family offers the best performance with hardware floating-point support and sub-microsecond execution times. For most applications, the REAL data type provides sufficient precision. For high precision applications, the LREAL data type is available on the S7-1500 and S7-400. The key to successful programming is to select the correct data type, check for invalid inputs (especially for SQRT), and manage rounding errors by using a tolerance value.
Yueyang Tongtu E-commerce Co., Ltd. supplies Siemens PLC units with full technical support. We provide programming guidance and troubleshooting assistance for all Siemens PLC models. Our technical team can help you optimize your floating-point calculations for performance and precision.