Infosys在阅读器中打开 / AI 翻译

PLC · 0 次阅读

RealIsNaN

This function tests whether a value is NaN (Not a Number). If the return value is TRUE, the value is NaN.

RealIsNaN 1: Return value

Name

Type

Description

RealIsNaN

BOOL

If the return value is TRUE, the value is NaN.

RealIsNaN 2: Inputs

VAR_INPUT
    x        : REFERENCE TO REAL;
END_VAR

Name

Type

Description

x

REFERENCE TO REAL

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) or NOT(a = a).

The fact that NaN values reproduce themselves when used in further calculations is advantageous in that invalid values cannot be overlooked.

CAUTION

Software malfunctions

NaN values can lead to potentially dangerous malfunctions of the software concerned!

  • Only use expressly approved NaN values, specifically as control values in motion control and drive control functions.

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.

  • Switch off the FP exceptions if NaN values are to be used and processed in the application.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.4024.32

PC or CX (x86, x64, Arm®)

Tc2_Utilities (System) >= 3.3.50.0