This is my first time to mention bugs, if there are inappropriate places please guide.
Describe the bug
An error occurred during division of an unsigned variable.
I tested the variable types BYTE, USINT, UINT, and UDINT. They performed division calculations in accordance with signed types.
Since both USINT and UINT are extended to 32-bit calculations, this error is avoided.However, I believe that extended computing is also incorrect, which consumes unnecessary resources.
To Reproduce
You can see that in the division calculation, sdiv is used for signed integer division
{external}
FUNCTION printf : DINT
VAR_INPUT {ref}
format : STRING;
END_VAR
VAR_INPUT
args: ...;
END_VAR
END_FUNCTION
FUNCTION main:DINT
VAR
a:BYTE;
b:BYTE;
c:BYTE;
aa:USINT;
bb:USINT;
cc:USINT;
aaa:UINT;
bbb:UINT;
ccc:UINT;
aaaa:UDINT;
bbbb:UDINT;
cccc:UDINT;
END_VAR
b:=64;
c:=255;
a:=b/c;
printf('a:%d',a);
aa:=bb/cc;
aaa:=bbb/ccc;
aaaa:=bbbb/cccc;
END_FUNCTION
This is my first time to mention bugs, if there are inappropriate places please guide. Describe the bug An error occurred during division of an unsigned variable. I tested the variable types BYTE, USINT, UINT, and UDINT. They performed division calculations in accordance with signed types. Since both USINT and UINT are extended to 32-bit calculations, this error is avoided.However, I believe that extended computing is also incorrect, which consumes unnecessary resources.
To Reproduce You can see that in the division calculation, sdiv is used for signed integer division
Expected behavior The correct way to do this is to use udiv for unsigned integer computation.
Tests The calculation in the above print is 192