SA0134: Explicit signed/unsigned conversionsPermalink

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 you have chosen the wrong data types for variables. For this reason, there are programming guidelines that require an explicit justification for data type conversions.

Importance: Low

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);

--> SA0134: Explicit signed/unsigned conversion from type 'ULINT' to type 'LINT'
--> SA0134: Explicit signed/unsigned conversion from type 'DINT' to type 'UDINT'
--> SA0134: Explicit signed/unsigned conversion from type 'BYTE' to type 'SINT'
--> SA0134: Explicit signed/unsigned conversion from type 'INT' to type 'WORD'
--> SA0134: Explicit signed/unsigned conversion from type 'SINT' to type 'LWORD'