Data Type: REAL, LREAL
The data types REAL and LREAL are floating-point types according to IEEE 754. Floating-point types are necessary when using decimal numbers and floating-point numbers in decimal notation or exponential notation.
Data Type | Smallest value number | Largest value number | Memory |
|---|---|---|---|
| 1.0E-44 | 3.402823E+38 | 32-bit |
| 4.94065645841247E-324 | 1.7976931348623157E+308 | 64 bits |
PROGRAM PLC_PRG
VAR
rMax: REAL := 3.402823E+38; // Largest number
rPosMin : REAL := 1.0E-44; // Smallest positve number
rNegMax: REAL := -1.0E-44; // Largest negative number
rMin: REAL := -3.402823E+38; // Smallest number
lrMax: LREAL := 1.7976931348623157E+308; // Largest number
lrPosMin : LREAL := 4.94065645841247E-324; // Smallest positve number
lNegMax: LREAL := -4.94065645841247E-324; // Largest negative number
lrMin: LREAL := -1.7976931348623157E+308; // Smallest number
END_VARImportant
Support for the LREAL data type depends on the target device in use. See the respective documentation as to whether or not the 64-bit type LREAL is converted to REAL or remains as LREAL when compiling the application. Conversion may result in the loss of information.
Important
If the value of the REAL/LREAL number is outside of the value range of the integer, then an undefined result is yielded from a data type conversion from REAL or LREAL to SINT, USINT, INT, UINT, DINT, UDINT, LINT, or ULINT. The result depends on the target system. An exception error is also possible. To get code that is independent of the target system, the application has to catch out-of-range violations.
If the REAL/LREAL number is within the value range of the integer data type, then the conversion operates the same way on all systems.