Skip to main content

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

Example 57. Example
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:

  • sa_icon_message.png SA0134: Explicit signed/unsigned conversion from type 'ULINT' to type 'LINT'

  • sa_icon_message.png SA0134: Explicit signed/unsigned conversion from type from type 'DINT' to type 'UDINT'

  • sa_icon_message.png SA0134: Explicit signed/unsigned conversion from type from type 'BYTE' to type 'SINT'

  • sa_icon_message.png SA0134: Explicit signed/unsigned conversion from type from type 'INT' to type 'WORD'

  • sa_icon_message.png SA0134: Explicit signed/unsigned conversion from type from type 'SINT' to type 'LWORD'