Exponentiation (^)
Exponentiations can be performed using the ^ operator.
The syntax is
base^exponent
Where base and exponent can be numeric values or any complex expression.
Depending on the value of base and exp, the function behaves as follows:
- if the base > 0 the operation is performed just like in mathematics;
- if the base < 0 and the exponent is integer (positive/negative or 0) the operation is performed just like in mathematics;
- if the base < 0 and the exponent is not integer the result is 0;
- if the base = 0 the result is 0.
Example 1
Let's assume that we want to calculate
[LO].[X00000] := [C0000] ^ 2;
INPUT ACCOUNT C0000
| Account | CusDim1 | CusDim2 | Amount |
|---|---|---|---|
| C0000 | D11 | D21 | 10 |
| C0000 | D11 | D22 | 20 |
| C0000 | D12 | D22 | -5 |
OUTPUT ACCOUNT X0000
| Account | CusDim1 | CusDim2 | Amount |
|---|---|---|---|
| X0000 | D11 | D21 | 10 ^ 2 = 100 |
| X0000 | D11 | D22 | 20 ^ 2= 400 |
| X0000 | D12 | D22 | (-5) ^ 2 = 25 |
Example 2
Let's assume that we want to calculate
[LO].[X00000] := [C00000] ^ [D00000];
INPUT ACCOUNT C0000
| Account | CusDim1 | CusDim2 | Amount |
|---|---|---|---|
| C0000 | D11 | D21 | 9 |
| C0000 | D12 | D21 | 3 |
| C0000 | D11 | D22 | -2 |
| C0000 | D12 | D22 | -1 |
INPUT ACCOUNT D0000
| Account | CusDim1 | CusDim2 | Amount |
|---|---|---|---|
| D0000 | D11 | D21 | 2 |
| D0000 | D11 | D22 | 3 |
| D0000 | D12 | D22 | 3 |
| D0000 | D12 | D22 | 0.5 |
OUTPUT ACCOUNT X0000
| Account | CusDim1 | CusDim2 | Amount |
|---|---|---|---|
| X0000 | D11 | D21 | 9 ^ 2= 81 |
| X0000 | D11 | D22 | 3 ^ 3 = 27 |
| X0000 | D12 | D22 | (-2) * 3 = -8 |
| X0000 | D12 | D22 | (-1) * 0.5 =0 |