Mathematics

Botmother has helpers for all basic mathematical operations. All math heplers are linear.

Addition

You need helper "add" to add two numbers together:

{{add variable1 variable2}}

As in block helpers, in linear ones you can specify not only variables, but also literal values:

{{add 5 100}}

105 will be sent in a message.

If you need to add several numbers or variables, you can use helper "sum":

{{sum var1 var2 var3}}

It sums variable var1, variable var2 and variable var3.

Subtraction

We use helper "subtract" to subtract one number from another.

{{subtract variable1 variable2}}

Multiplication

We can use helper "multiply" to multiply one number by another:

{{multiply variable1 variable2}}

Division

We can use helper "divide" to divide one number by another:

{{divide variable1 variable2}}

Rounding

To round the resulting numbers to two decimal places, use component Assign a variable. Write value "var" in the final variable:

{{toRub variable}}

Where "variable" is the variable obtained after calculations.

If you need to create a variable with a fractional number after the dot, use helper:

{{toFixedRub variable ','}}

You can use the following helpers to round to an integer:

  • "floor" - always rounds down;
  • "ceil" - always rounds up;
  • "round" - rounds according to the rules of mathematics

Example:

{{variable 5.6}}
{{floor variable}}

As a result, the value of the variable will be rounded to 5.