Arithmetic Operators
  • 30 Jan 2024
  • PDF

Arithmetic Operators

  • PDF

Article summary

+ Operator

Used to sum two numbers.

Syntax: result = operand1 + operand2

Remarks: If one or both operands are Null expressions, result is a Null.  If both operands are Empty, result is an Integer.  However, if only one operand is Empty, the other operand is returned unchanged as result.

Example: This example adds input tag 1, input tag 2 and 20.5.

Result = GD(1) + GD(2) + 20.5      

- Operator

Used to find the difference between two numbers.

Syntax: result = operand1 - operand2

Remarks: If one or both operands are Null expressions, result is a Null.  If an operand is Empty, it is treated as if it were 0.

Example: This example subtracts input tag 2 from input tag 1.

Result = GD(1) - GD(2)   

* Operator

Used to multiply two numbers.

Syntax: result = operand1 * operand2

Remarks: If one or both operands are Null expressions, result is a Null.  Any operand that is Empty is treated as 0.

Example: The flow is the product of Input tag 1 (Total Flow) and Input tag 2 (Concentration).

ChemicalFlow = GD(1) * GD(2)    

/ Operator

Used to divide two numbers and return a floating-point result.

Syntax: result = operand1 / operand2

Remarks: If one or both operands are Null expressions, result is a Null.  Any operand that is Empty is treated as 0.

Example: The sum of two tags is divided by 1000.

Result = (GD(1) + GD(2))/1000    

^ Operator

Used to raise a number to the power of an exponent.

Syntax: result = number ^ exponent

Remarks: The number operand can be negative only if exponent is an integer value.  When more than one exponentiation is performed in a single expression, the ^ operator is evaluated as it is encountered from left to right. If either number or exponent is a Null expression, result is also a Null.

Example: This example squares (n^2) the value for Input tag 1.

Result = GD(1) ^ 2


Was this article helpful?

What's Next