beckhoff TE1200 — 4.2.1.3.14 SA0057: Possible loss of decimal points

Configuration | Rules nULINT : ULINT; nSINT : SINT; nINT : INT; nDINT : DINT; nLINT : LINT; bResult : BOOL; END_VAR bResult := (nBYTE >= BYTE#0); // => SA0055 bResult := (nWORD SA0055 bResult := (nDWORD >= DWORD#0); // => SA0055 bResult := (nLWORD SA0055 bResult := (nUSINT >= USINT#0); // => SA0055 bResult := (nUINT SA0055 bResult := (nUDINT >= UDINT#0); // => SA0055 bResult := (nULINT SA0055 bResult := (nSINT bResult := (nINT bResult := (nDINT bResult := (nLINT 4.2.1.3.13 SA0056: Constant out of valid range | SA0056: Constant out of valid range Samples: PROGRAM MAIN VAR nBYTE : BYTE; nWORD : WORD; nDWORD : DWORD; nUSINT : USINT; nUINT : UINT; nUDINT : UDINT; bResult :

BOOL; END_VAR bResult := nBYTE >= 355; // => SA0056 bResult := nWORD > UDINT#70000; // => SA0056 bResult := nDWORD >= ULINT#4294967300; // => SA0056 bResult := nUSINT > UINT#355; // => SA0056 bResult := nUINT >= UDINT#70000; // => SA0056 bResult := nUDINT > ULINT#4294967300; // => SA0056 4.2.1.3.14 SA0057: Possible loss of decimal points | SA0057: Possible loss of decimal points Samples: TE1200 45 Version: 2.11.1 Function Determines literals (constants) outside the valid operator range. Reason The message is output in cases where a variable is compared with a constant that lies outside the value range of this variable. The comparison then returns a constant TRUE or FALSE.

This indicates a programming error. Importance High Function Determines statements with possible loss of decimal points. Reason A piece of code of the following type: nDINT := 1; fREAL := TO REAL(nDINT / DINT#2); _ can lead to misinterpretation. This line of code can lead to the assumption that the division would be performed as a REAL operation and the result in this case would be REAL#0.5. However, this is not the case, the operation is performed as an integer operation, the result is cast to REAL and fREAL receives the value REAL#0. To avoid this, you should use a cast to ensure that the operation is performed as a REAL operation: fREAL := TO REAL(nDINT) / REAL#2; _ Importance Medium