Navigation: Realtest Script Language > Formula Syntax >

Operators

 

 

 

 

The following table lists all of the operators can be used in any RealTest script formula.

The general structure of a formula is term operator term.

The definition of term in this structure is ... any formula.

The examples in the table below show the simplest possible structure, with just a number on either side of each operator.

 

Operator

Alternative

Precedence Rank

Description

Example

()

 

1

parentheses

(1+1)*2 is 4

+ -

 

2

unary plus or minus

+2 + -2 is 0

NOT

!

2

logical not

NOT false is true

^

 

3

power, as in x^y (x to the power y)

9 ^ 2 is 81

*

 

4

multiplication

 9 * 2 is 18

/

 

4

division

6 / 2 is 3

MOD

%

4

modulo (remainder after division)

10 MOD 3 is 1

+

 

5

addition

2 + 2 is 4

-

 

5

subtraction

9 - 2 is 7

>

 

6

greater than

7 > 5 is true

>=

 

6

greater than or equal to

7 >= 7 is true

<

 

6

less than

7 < 5 is false

<=

 

6

less than or equal to

7 <= 7 is true

=

==

7

is equal to

7 = 7 is true

<>

!=

7

not equal to

7 <> 7 is false

AND

&&

8

logical and

true AND false is false

OR

||

9

logical or

true OR false is true

 

The Precedence Rank column comes into play when formulas include more than one operator. Lower numbers mean higher precedence.

Operators with higher precedence rank are evaluated first, no matter where they are in the formula.

Operators with the same precedence rank are evaluated from left to right.

The best practice, to avoid confusion, is to use parentheses to make precedence explicit in your formulas.

A couple of examples to clarify this:

"value1 + value2 * value3" would be the same as "value1 + (value2 * value3)", because * has higher rank than +.

"condition1 OR condition2 AND condition3" would be the same as "condition1 OR (condition2 AND condition3)" because AND has higher rank than OR.

Special note about division:

RealTest formulas allow division by zero. Anything divided by zero is zero. Though this is mathematically incorrect, it removes the unnecessary complexity of having to check that every divisor is non-zero in your own formulas.

 

 

 

 

Copyright © 2020-2024 Systematic Solutions, LLC