beautypg.com

Rockwell Automation GMLC Reference Manual User Manual

Page 502

background image

Publication GMLC-5.2 - November 1999

Expression Operators

465

Exponentiation

^

Use the caret to raise an element to a power. For example, the following
expression evaluates as 25. Both the base (5 in the example above) and
the exponent (2 in the example above) may be constants, variables, or
expressions.

5^2

//

Integer Quotient

The double slash provides the quotient between two elements. It is similar
to the single slash floating point divide except that the result is always an
integer—all fractional information is truncated. Use Integer Remainder
(@) to determine the remainder when two elements are divided (see
below). For example, the following expression evaluates as 1.

100//60

Integer division is useful to calculate the number of times one element can
be divided into another. For example, in a feeding application, the number
of pieces cut is equal to the quotient of the total material fed and the
length of each piece. Thus, the following expression determines the
number of pieces cut at any time (assuming that the actual position of
Axis 0 was zero when the machine was started).

Actual_Position_AXIS0//Cut_Length

Specifically, if the current actual position of Axis 0 is 1285.39 position
units and the Cut_Length variable is 25, the expression above evaluates to
51 indicating that 51 pieces have been cut.

Integer Remainder

@

The @ symbol provides the integer remainder when two elements are
divided. It is similar to the double slash integer divide except that it
provides only the integer remainder after the division is performed. For
example, the following expression evaluates as 40, since 60 goes into 100
once with a remainder of 40.