NexJ Logo

Formula operators

Operators are used to perform mathematical, comparative, and logical calculations on values in field control expressions.

Syntax

<first_value> <operator> <second_value>

The () math operator and ! logical operator use a different notation than other operators. See the tables for descriptions and examples of their usage.

Order of operations

Expressions that contain more than one operator are evaluated in a defined sequence called the order of operations. For example, the expression 2 + 10 / 5 returns 4, because the division operation 10 / 5 is evaluated first, then the addition operation is evaluated.

Order of operations in expressions

OrderOperationOperators
1Grouping()
2Exponent^
3Division and multiplication/, div, %, mod, *
4Addition and subtraction+, -
5Logical NOT!, NOT
6Comparison<, <=, >, >=
7Equality=, ==, !=, <>
8Logical AND&&, AND
9Logical OR||, OR

Math operators

Math operators are symbols that you use to perform arithmetic calculations on integer and number values. Math operators return an integer or number value.

Math operators for use in expressions

OperatorDescriptionExampleResult
+Adds the second number to the first number.5 + 27
-Subtracts the second number from the first number.5 - 23
*Multiplies the first number by the second number.5.0 * 210.0
/Divides the first number by the second number.5.0 / 22.5
^Raises the first number to the power of the second number.5 ^ 225.0
()Specifies that expressions within the brackets are evaluated first. Expressions outside the brackets are then evaluated using standard operator precedence.5.0 * (5 - 2)15.0
%, modEvaluates the modulo of two numbers. Divides the first number by the second number, then returns the remainder as the result.5 % 21
divPerforms integer division on two numbers. Divides the first number by the second number, then discards the remainder to return a whole number as the result. This is useful when you want to perform integer division on non-integer numbers.5.0 div 2.02.0

Comparison operators

Comparison operators are symbols that you use to determine equality or difference between values. Comparison operations return a Boolean value.

Comparison operators for use in expressions

OperatorDescriptionExampleResult
=, ==Compares the first value to the second value to determine if they are equal.5 = 2FALSE
!=, <>Compares the first value to the second value to determine if they are not equal.5 != 2TRUE
<Compares two values to determine if the first value is less than the second value.5 < 2FALSE
>Compares two values to determine if the first value is greater than the second value.5 > 2TRUE
<=Compares two values to determine if the first value is less than or equal to the second value.5 <= 2FALSE
>=Compares two values to determine if the first value is greater than or equal to the second value.5 >= 2TRUE

Logical operators

Logical operators are symbols that you use to perform logical operations on values. Logical operators return a Boolean value.

Logical operators for use in expressions

OperatorDescriptionExampleResult
&&, ANDCompares two expressions to determine if they are both true.(5 > 2) && (5 == 2)FALSE
||, ORCompares two expressions to determine if one or the other is true.(5 > 2) || (5 == 2)TRUE
!, NOTInverts a Boolean value or the Boolean result of a comparison or logical operation.!(5 > 2)FALSE