← All exercises

Modulo

easy

Outputs the remainder of dividing the dividend by the divisor.

What it teaches

The remainder left after integer division: 7 MOD 3 is 1. Its everyday job is wrapping — a cyclic buffer index, an every-Nth-part trigger, an encoder count folded back into one revolution. Two gotchas: the remainder follows the sign of the dividend, so -7 MOD 3 is -1 where school maths says 2; and DINT modulo by zero returns 0 instead of faulting.

Inputs and outputs

TagTypeDefaultDescription
In_DividendDINT7Value being divided
In_DivisorDINT3Value to divide by
Out_RemainderDINTRemainder of the division

Required behavior