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
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Dividend | DINT | 7 | Value being divided |
| In_Divisor | DINT | 3 | Value to divide by |
| Out_Remainder | DINT | — | Remainder of the division |
Required behavior
- Out_Remainder is the remainder left after dividing In_Dividend by In_Divisor.
- The remainder takes the sign of the dividend: -7 divided by 3 leaves -1, not 2.
- A divisor of 0 does not fault: Out_Remainder is 0.