LrealIsNaN
This function tests whether a value is NaN (Not a Number). If the return value is TRUE, the value is NaN.
Return value
Name | Type | Description |
---|---|---|
LrealIsNaN | BOOL | If the return value is TRUE, the value is NaN. |
Inputs
FUNCTION LrealIsNaN : BOOL
VAR_INPUT
x : REFERENCE TO LREAL;
END_VAR
Name | Type | Description |
---|---|---|
x | REFERENCE TO LREAL | Transfers the value being tested. |
The following points rank among the main features of NaN values:
- All arithmetic operations that use NaN as input data return NaN as the result.
- All relational operators =, !=, > < >= <= always return the value False if at least one of the operands is NaN.
- The standard C functions
isnan()
or_isnan()
or the PLC functions LrealIsNaN() and RealIsNaN (Tc2_Utilities library) return the value True if the argument has the value NaN. - The expression
isnan(a)
is equivalent to the expression!(a == a)
orNOT(a = a)
.
The fact that NaN values reproduce themselves when used in further calculations is advantageous in that invalid values cannot be overlooked.
| |
Software malfunctions NaN values can lead to potentially dangerous malfunctions of the software concerned!
|
Notice | |
Machine damage due to floating point exceptions (FP exceptions) Comparisons with NaN values can lead to an exception, which result in the runtime stopping and potentially machine damage.
|
Requirements
Development environment | Target platform | PLC libraries to be integrated (category group) |
---|---|---|
TwinCAT v3.1.4020 | PC or CX (x86, x64, Arm®) | Tc2_Utilities (System) >=3.3.16.0 |