Operators
Operators allow the expression writer to perform mathematical operations on numbers and variables within an expression.
There are standard expressions used by many programming languages which are available in Designer expressions. This page provides an overview and brief description of the available operators
Comparison operators
Comparison operators are useful when working with Logic functions.
- less
<
- (a < b
) returns true ifa
is strictly less thanb
- less equal
<=
- (a <= b
) returns true ifa
is less than or equal tob
- greater
>
- (a > b
) returns true ifa
is strictly greater thanb
- greater equal
>=
- (a >= b
) returns true ifa
is greater than or equal tob
- not equal
!=
- (a != b
) returns true ifa
is not equal tob
- equal
==
- (a == b
) returns true ifa
is exactly equal tob
Note that for non-integer numeric values (i.e. floating point values) comparisons can be surprising. When comparing floating point values, consider reworking the comparison to be more fuzzy. For example, a == b
could be rewritten to be abs(a-b) < 0.01
which ensures that even if there is a tiny difference between the numbers, the comparison does what the expression writer would expect.
Logical operator
The logical not operator is useful when working with Logic functions.
- not
!
- (!a
) flip the truth value of the variable or sub-expression following the operator (true->false, and false->true)
Index operator
The index operator allows indexing into arrays of data.
- square brackets -
[]
- (array[i]
) returns thei
th value within thearray
variable
Arithmetic operators
Arithmetic operators allow the writer to combine numeric values within expressions using common arithmetic operations.
- addition -
+
- (a + b
) returns the sum ofa
andb
- subtraction -
-
- (a - b
) returns the result of subtractingb
froma
- multiplication -
*
- (a * b
) returns the product ofa
andb
- division -
/
- (a / b
) returns the quotient ofa
divided byb
- modulus -
%
(a % b
) returns the remainder ofa
divided byb