Arithmetic operators – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 115

Advertising
background image

Chapter
Expressions, Variables and Operators

9

9 -5

The BASIC module contains a complete set of two-operand and
one-operand arithmetic operators.

The general form of all two-operand instructions is:

(expr) OP (expr), where OP is one of these arithmetic operators.

Add ( + )

Use the addition operator to add the first and the second expressions
together.

>PRINT 3+2

Result:

5

Divide ( / )

Use the division operator to divide the first expression by the second
expression.

>PRINT 100/5

Result:

20

Exponentiation ( **)

Use the exponentiation operator to raise the first expression to the power of
the second expression. The maximum power to which you can raise a
number is 255. (See also EXP page 9 -13)

>PRINT 2**3

Result:

8

Multiply ( * )

Use the multiplication operator to multiply the first expression by the
second expression.

>PRINT 3*3

Result:

9

Subtract ( – )

Use the subtraction operator to subtract the second expression from the
first expression.

>PRINT 9-6

Result:

3

Arithmetic Operators

Advertising