PDA

View Full Version : equation???



always1
06-07-2002, 02:09 PM
Hi,
Can someone explain to me the following equation means to what. Expecially the "%" symbol refer to what.

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

Thanks

chowe6685
06-07-2002, 02:21 PM
% 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

always1
06-07-2002, 02:27 PM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif

harsman
06-08-2002, 06:28 AM
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.