The data types REAL
and LREAL
are floating-point types according to IEEE 754. They are necessary when using decimal
numbers and floating-point numbers in decimal notation or exponential notation.
Example
PROGRAM PLC_PRG VAR rMax: REAL := 3.402823E+38; // Largest number rPosMin : REAL := 1.0E-44; // Smallest positive 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_VAR




NOTICE

Support for the LREAL
data type depends on the target device in use. Refer to 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.




NOTICE

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 must catch value
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.
See also