equation???

Hi,
Can someone explain to me the following equation means to what. Expecially the “%” symbol refer to what.

move = (move - 5) % 360;
glutPostRedisplay();

Thanks

% is modulus, this just decrements move my 5 every time it is called. Presumably its intended to keep move between 0 and 360 though it should be move = (move+5) % 360 for that to work properly

Originally posted by chowe6685:
% is modulus, this just decrements move my 5 every time it is called. Presumably its intended to keep move between 0 and 360 though it should be move = (move+5) % 360 for that to work properly

Yup, i got it. Thanks

Maybe I misunderstood something, but modulus doesn’t decrement.

If c=a % b then c is the remainder of the integer division a/b. So 10%6 is 4 for example. Whether the result of a modulus is allowed to be negative varies, although I think it’s allowed in C, but I’m not sure.