DOCS

# Arithmetic Operators

# Addition Operator ( + )

The addition operator (+) is used to add one value to another value where both values are of the same data type. The resultant value will be the result of adding the first value to the second value to produce a new value whose type will be the same as the input values. The valid input types are BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, STRING and VARIANT. Where two strings are added the result will be the concatenation of the first value and second values. e.g. “ABC” + “DEF” will result in “ABCDEF” being returned.

## Example: Use Addition Operator to Add 5.0 to 4.0 resulting in 9.0

```
SUB MAIN
DIM X AS DOUBLE
X = 5.0 + 4.0
END SUB
```

# Subtraction Operator ( - )

The subtraction operator (-) is used to subtract one value from another value where both values are of the same data type. The resultant value will be the result of subtracting the second value from the first value to produce a new value whose type will be the same as the input values. The valid input types are BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE and VARIANT.

## Example: Use Subtraction Operator to Subtract 3.0 from 10.0 resulting in 7.0

```
SUB MAIN
DIM X AS DOUBLE
X = 10.0 - 3.0
END SUB
```

# Multiplication Operator ( * )

The multiplication operator (*) is used to multiple one value by another value where both values are of the same data type. The resultant value will be the result of multiplying the first value by the second value to product a new value whose type will be the same as the input values. The valid input types are BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE and VARIANT.

## Example: Use Multiplication Operator to Multiply 5.0 by 3.0 resulting in 15.0

```
SUB MAIN
DIM X AS DOUBLE
X = 5.0 * 3.0
END SUB
```

# Division Operator ( / )

The division operator (/) is used to divide one value by another value where both values are of the same data type. The resultant value will be the result of dividing the first number by the second number to produce a new value whose type will be the same as the input values. The valid input types are BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE and VARIANT.

## Example: Use Division Operator to Divide 16.0 by 5.0 resulting in 3.2

```
SUB MAIN
DIM X AS DOUBLE
X = 16.0 / 5.0
END SUB
```

# Modulus Operator ( % )

The modulus (remainder) operator (%) is used to calculate the remainder that results from dividing one value by another value where both values are of the same data type. The resultant value will be the remainder that result after dividing the first integer number by the second integer number to produce a new value whose type will be the same as the input values. The valid input types are BYTE, SHORT, INTEGER, LONG.

## Example: Use Modulus Operator to find the remainder of dividing 16 by 5 resulting in 3 remainder 1

```
SUB MAIN
DIM X AS INTEGER
X = 16 % 5
END SUB
```

# Power Operator ( ** )

The power operator (**) is used to raise one value to the power of another value; The resultant value will be the result of raising the first value to the power of the second value to produce a new values whose type will be a DOUBLE. The valid input types are BYTE, SHORT, INTEGER, LONG, FLOAT amd DOUBLE.

## Example: Use Power Operator to raise 5.0 to the power 3.0 resulting in 125.0

```
SUB MAIN
DIM X AS DOUBLE
X = 5.0 ** 3.0
END SUB
```

# Negation Operator ( - )

The negation operator (-) is used to change the sign of the value to its immediate right to produce a new value whose type will be the same as the input value. The valid input types are BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE and VARIANT.

## Example: Use Negation Operator to change the sign of the calculation (3.0 * 2.0) resulting in -6.0

```
SUB MAIN
DIM X AS DOUBLE
X = -(3.0 * 2.0)
END SUB
```