I'm trying to execute a modulo operation with 2 numbers of type short
:
short short1 = 1; // or any other short value
short short2 = 2;
short result = short1 % short2;
But I get this compilation error:
Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?)
Why does the compiler think the result should be of type int
?
The result must be between 0 and min(short1, short2) and both those values are short
.