Solution
While LabVIEW does not have an explicit modulo operation, there are a variety of ways to perform modulo in LabVIEW.
The
Quotient & Remainder function is most straightforward. The Remainder output is the result of a modulo operation using truncated division. As such, Remainder has the same sign as the dividend and negative numbers are treated differently than in a traditional modulo operation.
- Formula Express VI and Formula Node
By using a
Formula Express VI or
Formula Node, you can type the formula for a modulo operation with two inputs and one output. This performs a traditional modulo operation
The image below shows the difference between modulo implemented in
Quotient & Remainder and modulo implemented in the
Formula Express VI and
Formula Node.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.