I am trying to understand the % remainder operator. In the reference section there is some example code as in:
int x = 0;
x = 7 % 5; // x now contains 2
x = 9 % 5; // x now contains 4
x = 5 % 5; // x now contains 0
x = 4 % 5; // x now contains 4
x = -4 % 5; // x now contains -4
x = 4 % -5; // x now contains 4
Where remainder = dividend % divisor;
and Remainder operation calculates the remainder when one integer is divided by another.
How are these numbers derived? The quotient of 7/5 is 1.4 So wouldn't the remainder be 0.4, not 2? Similar with the rest: 9/5 is 1.8 so the remainder is 0.8 not 4 as shown above. Doesn't seem to be rounding up. What am I not understanding?