# Operators

## Arithmetic operators

The following is the arithmetic operators defined in Macro Expert.

Operator Description Example
+ Adds two numbers. %=100 + 120%
- Returns the difference between two numeric expressions. %=100 - v_b%
* Multiplies two numbers. %=20 * v_b%
/ Divides two numbers. %=20 / v_b%
MOD
or \
Divides two numbers and returns only the remainder. %=v_b \ 10%
INT Divides two numbers and returns an integer result. %=25 INT 10%
POW Return the result of a number raised to a power (exponent). %=2 POW 3%

## Comparison Operators

The following are the arithmetic operators defined in Macro Expert.

Operator Description Example
> Greater than %=v_a > 10%
>= Greater than or equal to %=v_a >= 10%
< Less than %=v_a < 10%
<= Less than or equal to %=v_a <= 10%
!= Not equal to %=v_a != 10%
!== For string only, not exactly equal to %=v_a !=='Macro'%
= or == Equal to (case-insensitive for string comparison) %=v_a == 10%
=== Exactly equal to %=v_b === "Hello" %
^= For string only, return TRUE if the string starts with a given string. The comparing is case-insensitive. %=v_b ^= "Hel" %
^== For string only, return TRUE if the string starts exactly with a given string. %=v_b ^= "Hel" %
\$= For string only, return TRUE if the string ends with a given string. The comparing is case-insensitive. %=v_b \$= "llo" %
\$== For string only, return TRUE if the string ends exactly with a given string. %=v_b \$= "llo" %
LIKE For string only, return TRUE if the value on the left matches the right pattern. A pattern can include regular characters and wildcard characters %=v_b LIKE "He*o" %
LIKENC For string only, with no case sensitive, return TRUE if the value on the left matches the right pattern. A pattern can include regular characters and wildcard characters. %=v_b LIKENC "He*o" %
CONTAINS
or CT
For string only, return True if the string on the left contains a string. %=v_b CT "Hello" %
CONTAINSNC
or CTNC
For string only, with no case sensitive, return True if the string on the left contains contains string. %=v_b CTNC "Hello" %

## Logical Operators

The following are the arithmetic operators defined in Macro Expert.

Operator Description Example
AND Performs a logical conjunction on two Boolean expressions. %=v_a and v_b%
OR Performs a logical disjunction on two Boolean expressions. %=v_a or v_b%
XOR Performs a logical exclusion on two Boolean expressions. %=v_a xor v_b%
NOT Performs logical negation on a Boolean expression. %=not (v_a > v_b)%

## Bitwise Operators

The following are the bitwise operators defined in Macro Expert.

Operator Description Example
& Performs a logical bitwise AND on two integer expressions. %=v_a & v_b%
| Performs a logical bitwise OR on two integer expressions. %=v_a | v_b%
^ Performs a logical bitwise XOR on two integer expressions. %=v_a ^ v_b%
~ Performs a logical bitwise NOT on an integer expressions. %= ~v_a%

## Operator Precedence

When expressions contain operators from more than one category, they are evaluated according to the following rules:

• The arithmetic operators have the order of precedence described in Precedence Order, and all have greater precedence than the comparison, logical, and bitwise operators.

• All comparison operators have equal precedence, and all have greater precedence than the logical and bitwise operators, but lower precedence than the arithmetic operators.

• The logical and bitwise operators have the order of precedence described in the Precedence Order, and all have lower precedence than the arithmetic, comparison operators.

• Operators with equal precedence are evaluated left to right in the order in which they appear in the expression.

## Precedence Order

Operators are evaluated in the following order of precedence:

1. Logical bitwise NOT (~) and logical conditional negation (NOT)
2. Exponentiation (POW)
3. Multiplication and division (*, /)
4. Integer division (INT)
5. Modulus arithmetic (MOD)
6. Addition and subtraction (+, -)
7. Comparison operators (>, >=, <, <=, LIKE, LIKENC, CONTAINS, CONTAINSNC)
8. Equality and inequality (==, ===, !=, !==, ^=, ^==, \$=, \$==)
9. Logical bitwise conjunction (&)
10. Logical bitwise exclusive disjunction (^)
11. Logical bitwise inclusive disjunction (|)
12. Logical conditional conjunction (AND)
13. Logical conditional exclusive disjunction (XOR)
14. Logical conditional inclusive disjunction (OR)

## Overriding Precedence

You can use parentheses to force some parts of an expression to be evaluated before others. The following example illustrates this.

%= (8 + 4 ) * 20%
%= 8 * ( ( 20 + 4 ) * 20 )+4%