Skip to main content

math

in Default Functions
Authors list
Published: Aug 7, 2024|Last updated: Aug 7, 2024

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

ArgumentsCopy link to Arguments to clipboard

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

ExamplesCopy link to Examples to clipboard

Example


math example 1

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

Output:

9

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.

next pagerand
previous pagein_array

Please log in or register to submit a comment.

Page sections