beautypg.com

Using operators to modify values in expressions, Arithmetic operators, Arithmetic operators – 6 – Rockwell Automation FactoryTalk View Site Edition Users Guide User Manual

Page 552

background image

F

ACTORY

T

ALK

V

IEW

S

ITE

E

DITION

U

SER

S

G

UIDE

20–6

• •

String constant (“character string”)

Pi string (to represent the symbol

π)

FactoryTalk View replaces the string with its numeric value.

Using operators to modify values in expressions

To modify the values returned to an expression, use arithmetic, relational, logical, or
bitwise operators.

Arithmetic operators

Arithmetic operators calculate values based on two or more numeric values.

The following table describes the arithmetic operators, with examples. (In the examples,
tag1 = 5 and tag2 = 7.)

String operands

The + operator can be used to join string operands. For example, the expression hello +
world returns: helloworld.

Symbol

Operator

Example

+

addition

tag1+tag2
returns a value of 12

subtraction

tag1–tag2
returns a value of –2

*

multiplication

tag1*tag2
returns a value of 35

/

division

tag1/tag2
returns a value of 0.7142857

MOD, %

modulus
(remainder)

tag2 MOD tag1
returns a value of 2

The modulus operator is the remainder of one
number divided by another. For example, the
remainder of 13 divided by 5 is 3; so 13%5=3

Important: This operator is for integers only, not
floating point numbers.

**

exponent

tag1**tag2
returns a value of 78125

Be sure that any tag value you use as a divisor cannot at some point have a value of zero.
Expressions that attempt to divide a number by zero produce an error at run time.