# Arithmetic Functions and Operators

Help Contents

## Introduction

Fernhill SCADA supports these arithmetic functions and operators:

FunctionOperatorParameter TypeParametersDescription
MUL*ANY_MAGNITUDE2-NMultiplication
SUB-ANY_MAGNITUDE2Subtraction
DIV/ANY_MAGNITUDE, ANY_NUM2Division
MODANY_INT2Modulo
EXPT**ANY_NUM2Raise to power
MOVE:=ANY1Assignment

Arithmetic functions ADD, and MUL accept a variable number of parameters. For example:

ADD( A, B, C ) is equivalent to A + B + C.

Division of integers, using the DIV function or the / operator, truncates towards zero. For example:

DIV( -11, 4 ) returns -3, and 11 / 4 returns 3.

The MOD function returns 0 (zero) when the second parameter is 0 (zero). The MOD function is equivalent to this code fragment:

```IF In2 = 0 THEN
OUT := 0;
ELSE
OUT := IN1 - (IN1 / IN2) * IN2;
END_IF;
```

## Examples

ExampleReturn Value
MUL(2, 3, 4)DINT#24
SUB(20, 7)DINT#13

## Standards Compliance

IEC 61131-3 Second Edition: Table 24.

IEC 61131-3 Third Edition: Table 29.

## Further Information

Generic Data Types

To learn about generic data types such as ANY_INT, ANY_NUM, ANY_MAGNITUDE.

Time Functions

To learn about arithmetic operations on date and time types.

Common Elements

To learn about other language Common Elements.

Glossary

For the meaning of terms used in Fernhill SCADA.