Modulo MOD

Dest = the remainder of A ÷ B.

TagAfter two scans
Count77
Remainder1
Two2

How it works

While the rung is true, writes what is left over after A ÷ B. It has the sign of A, so -7 MOD 2 is -1. Dividing by 0 is a fault and leaves Dest unchanged.

How it's used

Use MOD to act on every Nth item, such as every second box.

TagValue
BoxCount7
Odd1
Divert1

Box 7 leaves a remainder of 1, so Divert is on.

Operands

OperandData typeRead or write
ADINT, REAL or a numberReads
BDINT, REAL or a numberReads
DestDINT, REALWrites

Common mistakes

  • Expecting a positive remainder for a negative sourceThe remainder takes the sign of A. -7 modulo 2 is -1.