Arithmetic Operation

 

+ Operator

 

+ Operator adds the values on the left and right side of the operator.
Format: Expression1 + Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.


Example

Example

Description

DW500 := DW00 + 10;

The sum of D00 and 10 is substituted to D500.

DW00 := 20;

DW01 := 30;

DW10 := DW00 + DW01;

The sum of D0 and D1 (=50) is substituted to D10.

 

 

- Operator

 

- Operator subtracts the value on right side of it from the value on the left side.

Format: Expression1 – Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.


Example

Example

Description

DW500 := 20 - 10;

10 is substituted to D500

DW00 := 30;

DW01 := 20;

DW10 := DW00 - DW01;

10 (The result of D0 – D1) is substituted to D10

 

 

* Operator

 

* Operator multiplies the values on the left and right side of the operator.

Format: Expression1 * Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.


Example

Example

Description

DW00 := 3;

DW01 := 2;

DW10 := DW00 * DW01;

6 (The result of 3*2) is substituted to D10.

 

 

/ Operator

 

/ Operator divides the value of the left side by the value on the right side.

Format: Expression1 / Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
If the value of Expression 2 is an error occurs.


Example

Example

Description

DW00 := 10;

DW01 := 2;

DW10 := DW00 / DW01;

5 (The result of 10/2) is substituted to D10

 

  • Division of integers outputs the result in integer. For example, "DW10 := 3 / 2;" will result in substituting "1" to DW10.

 

 

Modular (MOD) Operator

 

MOD Operator is to acquire the remainders of the value on the left side divided by the value on the right side.

Format: Expression1 MOD Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
If the value of Expression 2 is an error occurs.
The result of Expression 1 should be a positive number.


Example

Example

Description

DW00 := 10;

DW01 := 3;

DW10 := DW00 MOD DW01;

1 (The remainder of 10/3) is substituted to D10

 

 

Index (**) Operator

 

** Operator multiplies the base (the value on the left) as many times as the index (the value on the right).

Format: Expression1 ** Expression2
In Expression1 and 2, a constant, PLC Device variable (the value that PLC Device has) and the Expressions listed in [Expressions] can be used.
Example

Example

Description

DW00 := 10;

DW01 := 3;

DW10 := DW00 ** DW01;

1000 (The result of multiplying 10 3 times – 10*10*10) is substituted to D10.