Owner manual
Table Of Contents
- 5370-ND016, Bulletin 5370 Color CVIM Module MATH-PAK Option User's Manual
- Important User Information
- Table of Contents
- 1 - Using This Manual
- 2 - Introduction to the MATH-PAK Option
- 3 - Installation
- 4 - Defining Formulas
- 5 - Analysis Functions and Runtime Displays
- A - Color CVIM Communications with MATH-PAK Installed
- Index
- Back Cover

Chapter 4
Defining Formulas
4–23
Modulo operator: %
Format/Usage: The modulo operator (%) performs the “long division”
operation on one operand by a second operand, and yields the whole number
remainder of that division operation. In general, use two operands, placing
the modulo operator in the formula between the two operands. The left
operand is the dividend, the right operand is the divisor.
The modulo operator can be applied in formulas, for example, to produce
binary values from decimal-based integer values.
Example usage: Use the modulo operator to calculate a 5-place “binary”
result from a gage 1 object-counting result (for values 0–31 decimal), using a
series of 10 formulas:
Formula 1:
GAGE1 % 2
Formula 2: GAGE1 / 2
Formula 3: RSLT2 % 2
Formula 4: RSLT2 / 2
Formula 5: RSLT4 % 2
Formula 6: RSLT4 / 2
Formula 7: RSLT6 % 2
Formula 8: RSLT6 / 2
Formula 9: RSLT8 % 2
Formula 10: RSLT9
*
10000 + RSLT7
*
1000 + RSLT5
*
100 + RSLT3
*
10 + RSLT1
For example, if the gage 1 result were 19:
Formula 1:
19 % 2 (RSLT1=1)
Formula 2: 19 / 2 (RSLT2=9)
Formula 3: 9 % 2 (RSLT3=1)
Formula 4: 9 / 2 (RSLT4=4)
Formula 5: 4 % 2 (RSLT5=0)
Formula 6: 4 / 2 (RSLT6=2)
Formula 7: 2 % 2 (RSLT7=0)
Formula 8: 2 / 2 (RSLT8=1)
Formula 9: 1 % 2 (RSLT9=1)
Formula 10: 1
*
10000 + 0
*
1000 + 0
*
100 + 1
*
10 + 1 (RSLT 10=10011)
In the above example, the result of formula 10 is 10011, which, if interpreted
as a binary value, would equal 19 (decimal).