Modulo

Arithmetic Pure
Modulo
A 0
Result
B 1

Description

Pure function returning the remainder of a divided by b. A modulo of zero fails the pipeline.

When to use

Use Modulo to test divisibility, wrap a counter around a range, or recover the leftover portion after integer division with Divide. A common pattern is to feed the result into Equals with b = 0 to detect even numbers or cycle boundaries. Guard against a zero divisor just as you would with Divide.

Pins

Input pins

Pin Type Default Notes
A integer 0 The dividend.
B integer 1 The divisor. Must not be zero — a zero value fails the pipeline.

Output pins

Pin Type Notes
Result integer The remainder after dividing a by b.

Example

Send a notification only on every fifth iteration of a loop. Wire the loop index into the A input of Modulo with B set to 5, then feed the Result output into the A input of Equals with B set to 0. Connect the Result output of Equals to the Condition input of Branch — the True execution output fires only on iterations 0, 5, 10, and so on.

See also