I got this c++ macro and wonder what they mean by code%2 (the percentage sign) ?
#define SHUFFLE_STATEMENT_2(code, A, B)
switch (code%2)
{
case 0 : A; B; break;
case 1 : B; A; break;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is for taking a modulus.
Basically, it is an integer representation of the remainder.
So, if you divide by 2 you will have either 0 or 1 as a remainder.
This is a nice way to loop through numbers and if you want the even rows to be one color and the odd rows to be another, modulus 2 works well for an arbitrary number of rows.