# % explanation (buttonPushCounter % 4 == 0)

from the arduino example "State change detection (edge detection)" i don't understand the % part

`````` (buttonPushCounter % 4 == 0)
``````

How do i have to read it? Procent (pro 100) 4 is 0? doesn't make sense to me... :confused:

Thanks...

Modulo operator,

CaptainPicar3d: from the arduino example "State change detection (edge detection)" i don't understand the % part

`````` (buttonPushCounter % 4 == 0)
``````

How do i have to read it? Procent (pro 100) 4 is 0? doesn't make sense to me... :confused:

No, the percent operator in C/C++ stands for "modulo division!

x modulo y (x%y) has the meaning: find the integer remainder of the integer division x/y.

Examples

0%4 is 0 (remainder 0 in a division by 4)

1%4 is 1 (remainder 1 in a division by 4)

2%4 is 2 (remainder 2 in a division by 4)

3%4 is 3 (remainder 3 in a division by 4)

4%4 is 0 (remainder 0 in a division by 4)

o if you have an expression like (variable% 4 == 0) has the meaning of 'true', when the division by 4 remainder is 0 (false otherwise).

(variable% 4 == 1) has the meaning of 'true', when the division by 4 remainder is 1(false otherwise).

Thanks for the explanations and examples, now its all clear to me. Very useful :)

@CaptainPicar3d What does this do?

X++ ; X = X % 10;

.

LarryD: @CaptainPicar3d What does this do?

X++ ; X = X % 10;

.

trick question...

nothiing.