Operators
Arithmetic operators
The standard arithmetic operators + - * / are evaluated with standard algebraic priority. That is, multiplication and division are evaluated first, then addition and subtraction. A different order of calculation can be forced with parentheses ( ).
Cube rules do not divide by a value smaller that 5e-7 (5 * 10-7) to prevent several potential issues related to the characteristic of the utilized floating-point arithmetic:
- Precision loss: Dividing by a very small number can result in a very large number, potentially leading to precision loss. This occurs because floating-point numbers have finite precision, and very large numbers might not be accurately represented.
- Overflow: Dividing by an extremely small number can result in an overflow error, where the result exceeds the maximum value representable by the data type.
- Numerical instability: Divisions involving very small numbers can cause numerical instability, particularly in algorithms sensitive to precision, such as numerical solvers or optimizations.
Strings
There are no operators to manipulate strings. This can be achieved through text rule functions such as INSRT, SUBST, and others.
Comparative operators
These comparative operators can be used in rule formulas and especially in the conditions of an IF function:
- N1 > N2 greater than
- N1 < N2 less than
- N1 = N2 equal (works for numbers and strings, the types of its operands are automatically detected)
- N1 @= N2 equal (works for strings only)
- N1 <> N2 not equal to
- N1 >= N2 greater than or equal to
- N1 <= N2 less than or equal to
Cube rules treat two values as equal if they differ by less than 1e-10 (10-10).
This is a common practice in numerical computing and is known as using a tolerance or epsilon for equality checks. This approach can have several impacts, mostly positive, especially in the context of the floating-point arithmetic that OLAP is using:
- Avoiding precision errors: Floating-point numbers have limited precision and small differences can arise due to rounding errors. By considering two numbers as equal if they differ by a very small amount, errors can be avoided that might arise from these minor differences.
- Stability in algorithms: OLAP numerical algorithms require comparisons between floating-point numbers. Using a tolerance helps to ensure that the algorithm behaves consistently, even in the presence of small numerical rounding errors.
- Improved robustness: In practical applications, such as simulations, it is often not necessary to distinguish between two values that are very close to each other. Using a tolerance makes OLAP more robust and less sensitive to insignificant fluctuations.
Logical operators
These logical operators can be used in rule formulas and especially in the conditions of an IF function:
- AND - example: (X < Y) AND (X > Z)
A synonym for AND is the ampersand. For example: (X < Y) & (X > Z)
- OR - example: (X < Y) OR (X > Z)
A synonym for OR is the percent sign. For example: (X < Y) % (X > Z)
- NOT - example: NOT(X < Y)
The expressions used in conjunction with logical operators must be enclosed in parentheses.