When there are several variables involved in the operation, the result type depends on the variable type that represents the largest range in the variables. For example, in the variable that participates in the operation, there is an int, a double floating-point type Double, a short integer, and the last result type is double.
int a = 1; int b = 2; Double c = (double) A/b;
In the above code, both A and B are integral types, but the conversion of (double) a converts a to an anonymous variable that is of type double. But note: A itself is still an int type, not a double type, so that a (double) A/b is a double type divided by an int type, and the result is a double type.
Modulo operator: use% representation.
int a = 5; int b = 3; int C = a% B;
The result is 2 because 5 divided by 3 results in 1 + 2.
The rule of modulus: The result symbol of the modulo is always the same as the sign of the divisor.
int a = 5; int b =-3; int C = a% B;
Dividend is 5, then the result of modulo is 2;
int a =-5; int b = 3; int C = a% B;
Dividend is-5, then the result of modulo is-2;
Java record-I-operator Operator