The math function can be used to perform calculations, and the following operators can be utilized:

+, -, /, *, abs, ceil, cos, exp, floor, log, log10, max, min, pi, pow, rand, round, sin, sqrt, srans and tan 


Arguments

ArgumentDescription
equationThe equation to execute
formatThe format of the result based on the sprintf method in PHP
assignTemplate variable the output will be assigned to

Examples

math example1

{{$height=4}}
{{$width=5}}
{{math equation="x + y" x=$height y=$width}}

Output:

9

math example2

{{$row_height = 10}}
{{$row_width  = 20}}
{{$col_div       = 2}}

{{math equation="height * width / division"
       height=$row_height
       width=$row_width
       division=$col_div}}

Output:

100

math example3

{{math equation="x + y" x=4.4444 y=5.0000 format="%.2f" assign="answer"}}
{{$answer}}

Output:

9.44

math4

{{math equation=rand (0,10)}}

Output:

4 (random number between the 0 and 10)

* This can also be achieved using the rand function.