# Expressions and the Expression Wizard

Expressions

## Expressions

To update a number variable with a new value, you can provide a new value directly, or you can define an expression from which the new value can be calculated.

The expressions you can define are the normal arithmetic expressions such as

``````(3 * 4)
``````

Simple expressions, but no operations, blocks of code, control flow statements.

It supports a syntax that is common to most programming languages, including systems such as Excel.

Of course, what makes this useful is that you can calculate a new value for a variable with an expression which includes other values from the Process.

The way you do this is by building the expression as normal, but quoting other values which you want to include.

So if you have a variable called amount and you want an expression to calculae 16% tax, you could use the expression:

``````({amount} * 16/100)
``````

## Expression Wizard

As you are editing an update expression, you may well have forgotten exactly what name you gave to a particular value in the Process.

Instead of having to quit the editor to find out, you can make use of the Expression Wizard.

Ths formulates expressions for you, and then offers you the ability to copy and paste them in.

So you don’t need to remember:

Anything really - because this is a 100% no code system, and to remember lots of arbitrary things is not fun.

## Math Functions

To build expressions use the familiar operators for multiplication,division, addition and subtraction:

You can also make use of some mathematical functions.

We will list them below, but please note they are also available for reference via the Expression Wizard

### Examples

To calculate the value of amount to the power of 10, we could have the following expression:

``````pow({amount},10)
``````

Expression to round the value of amount to the nearest integer

``````round({amount})
``````

## Constants available

Constant ´ Notes
e Base of the natural logarithms 2.718281828459045
ln2 Natural logarithm of 2 0.6931471805599453
ln10 Natural logarithm of 10 2.302585092994046
log2e Base-2 logarithm of e 1.4426950408889634
log10e Base-10 logarithm of e 0.4342944819032518
pi The PI constant 3.1415926535897932
sqrt1_2 Square root of 1/2 0.7071067811865476
sqrt2 Square root of 2

## Division by zero and NaN (Not a number)

When you are calculating numbers based on other numbers, sometimes you get unfortunate situations.

One of them is when you are wanting to divide x by y, but the y has the value zero. Division by zero_ is impossible and yields infinity, which is most likely not what you intended

To avoid a crash, for cases of division by zero, we arbitarily / pragmatically assign the result to be 0.

Similarly, if there is a division by zero with a multiplication (e.g. (0/0)*100)), the result is NaN which is Not A Number.

In such a case, we also arbitarily assign the result to be 0.