SA0134: Explicit signed/unsigned conversions
Detects explicit conversions from signed data types to unsigned data types and the other way around
Justification: Excessive use of type conversions may indicate that wrong data types for variables have been selected. For this reason, there are programming guidelines that require an explicit justification for data type conversions.
Importance: Low
PROGRAM PLC_PRG VAR byVar :BYTE; udiVar : UDINT; uliVar : ULINT; lwVar : LWORD; wVar : WORD; siVar : SINT; iVar : INT; diVar : DINT; liVar : LINT; END_VAR
liVar := ULINT_TO_LINT(uliVar); udiVar := DINT_TO_UDINT(diVar); siVar := BYTE_TO_SINT(byVar); wVar := INT_TO_WORD(iVar); lwVar := SINT_TO_LWORD(siVar);
Output in the Messages view:
SA0134: Explicit signed/unsigned conversion from type 'ULINT' to type 'LINT'
SA0134: Explicit signed/unsigned conversion from type from type 'DINT' to type 'UDINT'
SA0134: Explicit signed/unsigned conversion from type from type 'BYTE' to type 'SINT'
SA0134: Explicit signed/unsigned conversion from type from type 'INT' to type 'WORD'
SA0134: Explicit signed/unsigned conversion from type from type 'SINT' to type 'LWORD'