Named constants

Named constants 1:

Available from TwinCAT 3.1 Build 4026.25

Special values, such as NaN (Not a Number), are now provided as type-safe constants. The LREAL_CONST namespace provides access to the following variables:

Constant

Meaning

DEFAULT

Application-specific default value (positive)

IGNORE

Marker value “do not evaluate”

INVALID

Marker value for invalid size

MAXIMUM

Largest finite positive value

DEFAULT_NEGATIVE

Application-specific default value (negative)

MAXIMUM_NEGATIVE

Largest finite negative value

NAN

Not a Number

INFINITY

Positive infinity

INFINITY_NEGATIVE

Negative infinity

Example: Usage

VAR
    fNumerator : LREAL;
    fDenominator : LREAL;
    fResult : LREAL
END_VAR
IF fDenominator = 0 THEN
    fDenominator := LREAL_CONST.NAN;// invalid: division by zero
END_IF
    fResult := fNumerator / fDenominator;