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
Argument | Description |
---|---|
equation | The equation to execute |
format | The format of the result based on the sprintf method in PHP |
assign | Template variable the output will be assigned to |
Examples
Example
Example
math example 2
{{$row_height = 10}}
{{$row_width = 20}}
{{$col_div = 2}}
{{math equation="height * width / division"
height=$row_height
width=$row_width
division=$col_div}} copy
Output:
100
Example
math example 3
{{math equation="x + y" x=4.4444 y=5.0000 format="%.2f" assign="answer"}}
{{$answer}} copy
Output:
9.44
Example
math example 4
{{math equation=rand (0,10)}}
Output:
4 (random number between the 0 and 10)
* This can also be achieved using the rand function.
Please log in or register to submit a comment.