NaN values

In some cases error handling by error codes is not the best choice, in particular if operations return undefined values on account of unusual, but in principle possible input data, or if values are to be excluded from the processing.

The IEEE 754 standard defines symbolic values of the category NaN (Not a Number) for these purposes. In the following situations these are generated or taken into account in the TwinCAT 3 Condition Monitoring library:

The ability of a function block to create NaN values is noted in its description.

The following points rank among the main features of NaN values:

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.

Further explanations on the option to switch the FP exceptions off and on can be found in chapter Task settings.