Skip to content

Mathematical Operations

Special functions for performing mathematical operations in a bot

{{ sum(1, 2) }} - Sum of numbers

Sum of user variables: {{ sum($variable1, $variable2) }}

Sum of multiple values: {{ sum($variable1, 1, 2) }}

Function alias: {{ сумма(1, 2) }}

{{ diff(4, 2) }} - Difference of numbers

Difference of user variables: {{ diff($variable1, $variable2) }}

Difference of multiple values: {{ diff($variable1, 1, 2) }}

Function alias: {{ разность(4, 2) }}

{{ multiplication(2, 2) }} - Product of numbers

Product of user variables: {{ multiplication($variable1, $variable2) }}

Product of multiple values: {{ multiplication($variable1, 1, 2) }}

Function alias: {{ произведение(2, 2) }}

{{ div(4, 2) }} - Division of numbers

Division of user variables: {{ div($variable1, $variable2) }}

Division of multiple values: {{ div($variable1, 4, 2) }}

Function alias: {{ деление(4, 2) }}

{{ setSumVariablesIntoVariable("сумма", "а", "б") }} - Write sum of variables/numbers to a variable

The sum of variables and will be written to variable $cумма. Variable names in double quotes or numbers are passed to the function. Up to 100 arguments can be passed to the function.

{{ setMultiplicationVariablesIntoVariable("произведение", "а", "б") }} - Write product of variables/numbers to a variable

The product of variables and will be written to variable $произведение. Variable names in double quotes or numbers are passed to the function. Up to 100 arguments can be passed to the function.

abs - absolute value (modulus of a number)

  • {{ abs(-100) }} – converts to positive number 100
  • {{ abs($число) }} – converts the number contained in the "число" variable to a positive number

ceil - rounding a fraction up

  • {{ ceil(1.2) }} – converts to integer 2
  • {{ ceil($число) }} – converts the number contained in the "число" variable to an integer

floor - rounding a fraction down

  • {{ floor(1.9) }} – converts to integer 1
  • {{ floor($число) }} – converts the number contained in the "число" variable to an integer rounded down

max – finding the largest number

  • {{ max(1, 5) }} – returns number 5
  • {{ max(1, 5, 100, 4) }} – returns number 100
  • {{ max($число1, $число2, $число3) }} – returns the largest number contained in variables "число1", "число2", "число3"
  • {{ max($число1, $число2, 100, 200) }} – mixed parameters; you can pass an "unlimited" number of numbers and variables

min – finding the smallest number

  • {{ min(1, 5) }} – returns number 1
  • {{ min(1, 5, 100, 4) }} – returns number 1
  • {{ min($число1, $число2, $число3) }} – returns the smallest number contained in variables "число1", "число2", "число3"
  • {{ min($число1, $число2, 100, 200) }} – mixed parameters; you can pass an "unlimited" number of numbers and variables

pow – exponentiation

  • {{ pow(2, 2) }} – two squared, returns number 4
  • {{ pow(2, 3) }} – two cubed, returns number 8
  • {{ pow(2) }} – two to the zero power, returns number 1
  • {{ pow($число, $степень) }} – raises the number contained in the "число" variable to the power contained in the "степень" variable
  • {{ pow($число, 10) }} – mixed parameters

round – rounding a number

  • {{ round(1.123456789, 1) }} – rounds the number to 1.1
  • {{ round(1.123456789, 2) }} – rounds the number to 1.12
  • {{ round(1.123456789, 5) }} – rounds the number to 1.12346
  • {{ round(1.49) }} – rounds the number to 1
  • {{ round(1.5) }} – rounds the number to 2
  • {{ round($число, $точность) }} – rounds the number contained in the "число" variable with precision contained in the "точность" variable
  • {{ round(1.123456789, $точность) }} – rounds the number with precision contained in the "точность" variable

sqrt – square root

  • {{ sqrt(4) }} – returns 2
  • {{ sqrt(100) }} – returns 10
  • {{ sqrt(200) }} – returns 14.142135623731
  • {{ sqrt($число) }} – calculates the square root of the number contained in the "число" variable

In the LEADTEX personal account, 250+ lessons on chat bot and MiniApp development are already available, as well as the opportunity to join the largest developer community with 6000+ participants - Go to personal account.