MOD Function Question

Evening all,

Wonder if anyone can assist. I run the code below as a job but do not understand what print (nLoops mod 10) == 0; does. Can someone please explain because I cant work this one out.

static void ModTest(Args _args)
{
real nLoops = 1;
;
while (nLoops <= 88)
{
//print nLoops;
print (nLoops mod 10) == 0;

//pause;
// The X++ modulo operator is mod.
if ((nLoops mod 10) == 0)
{
break;
}
++ nLoops;
}
beep(); // Function.
pause; // X++ keyword.
}

The output I receive when running the code is:

0
0
0
0
0
0
0
0
0
1

I was expecting the raminder to be displayed!!!

And also what does it mean when you change:

(nLoops mod 10) == 0;
to
(nLoops mod 10) == 1;
or
(nLoops mod 10) == 2; for example.

Thanks and kind regards,
Tom

If you divide 4 / 2 you get 2 and remainder 0, so in X++ you have 4 mod 2 which evaluates to 0.

From your code snippet 10 mod 10 evaluates to 0 and (0 == 0) evaluates to 1.

Here is more information:

http://en.wikipedia.org/wiki/Modulo_operation

Your code will not print the remainder - if you want the remainder to print just use mod - x mod y

what your code returns is the result of the condition, like true or false - when remainder is zero it will return 1 and when remainder is not equals to zero it will return 0…