Cicode Programming Reference > Working with Operators > Using Mathematical Operators

Using Mathematical Operators

Standard mathematical operators allow you to perform arithmetic calculations on numeric variables - integers and floating point numbers.

Operator

Description

+

Addition

-

Subtraction

*

Multiplication

/

Division

MOD

Modulus (Remainder)

Example

The following are examples of mathematical operators

Command

PV12 = PV10 + PV11;

Comment

PV12 is the sum of PV10 and PV11

Command

Counter = Counter - 1;

Comment

The value of Counter is decreased by 1

Command

PV12 = Speed * Counter;

Comment

PV12 is the product of Speed and Counter

Command

Average = Total / ShiftHrs;

Comment

Average is Total divided by ShiftHrs

Command

Hold = PV12 MOD PV13;

Comment

If PV12 = 10 and PV13 = 8, Hold equals 2 (the remainder when PV12 is divided by PV13)

Command

Hold = PV12 MOD PV13;

Comment

If PV12 = 10 and PV13 = 8, Hold equals 2 (the remainder when PV12 is divided by PV13)

Note: Cicode uses the standard order of precedence, that is multiplication and division are calculated before addition and subtraction. In the statement A=1+4/2, 4 is divided by 2 before it is added to 1, and the result is 3. In the statement A=(1+4)/2 , 1 is first added to 4 before the division, and the result is 2.5.

You can also use the addition operator (+) to concatenate (join) two strings.

Operator

Description

+

Concatenate

Command

Message = "For info see " + "Supervisor";

Comment

Message now equals "For info see Supervisor"

For example:

See Also

Working with Operators

Using Cicode Files