Effects of the compiler settings on the execution

Accuracy and behavior of mathematical functions

Mathematical functions that are processing floating-point numbers (REAL, LREAL) might return different results on different target system s – in particular, if the result of the function are located within the threshold of the data type. This different inaccuracies of the mathematical functions is caused by the following factors:

  • the →target system itself,

  • the compiler used for the target system and

  • the configured optimization flags for the compiler.

Do not use blocks/variables with LREAL for Controllino or Arduino Nano

If you create an application for a →Controllino or an →Arduino Nano, avoid the usage of blocks/variables processing/returning LREAL values. The usage of such blocks/variables is possible but the LREAL values are processed with the accuracy of REAL values.

Known examples:

Target system

Result of the mathematical function TRUNC_DINT(REAL#3.402823466e+38);

→logi.RTS for Windows

-2147483648

→Raspberry Pi

2147483647

The RTOS32 compiler reports an error in case of a specific division.

If you are using the RTOS32 compiler, avoid a specific division (see the following example) in your application.

Example for ST-code
PROGRAM Program1
DIV(DINT#-2_147_483_648, DINT#-1);
END_PROGRAM

When building the application, the compilers report the expected warning overflow in constant division, undefined behavior. But the RTOS32 compiler also reports an error divide or mod by zero. Other compilers do accept the code – only the mentioned warning is reported. To avoid the reporting of the error when using the RTOS32 compiler, do not use a division with the above-mentioned negative integers.