Skip to content
Stef Heyenrath edited this page Apr 22, 2021 · 5 revisions

Custom Math Helpers

These helpers provide the ability to perform some calculations within a template.


Add

Summary Add two numbers
Returns Sum of inputs
Remarks
Parameters
input1 First input
input2 Second input

Example

Context

{
    "a": 1,
    "b": 2,
    "c": 3
}

Usage

<strong>result:</strong>
{{Math.Add a b}}
{{Math.Add b c}}
{{Math.Add c 4}}
{{Math.Add 4 5}}

Returns

<strong>result:</strong>
3
5
7
9

Ceiling

Summary Rounds input up to the nearest whole number
Returns Ceiling of input
Remarks
Parameters
input input

Example

Context

{
    "a": 1.23,
    "b": 2.45,
    "c": 3.67
}

Usage

<strong>result:</strong>
{{Math.Ceiling a}}
{{Math.Ceiling b}}
{{Math.Ceiling c}}
{{Math.Ceiling 4.89}}

Returns

<strong>result:</strong>
2
3
4
5

Divide

Summary Divide first input by second input
Returns Result of first input divided by second input
Remarks
Parameters
input1 First input
input2 Second input

Example

Context

{
    "a": 1,
    "b": 2,
    "c": 3
}

Usage

<strong>result:</strong>
{{Math.Divide a b}}
{{Math.Divide b c}}
{{Math.Divide c 4}}
{{Math.Divide 4 5}}

Returns

<strong>result:</strong>
0.5
0.666666666666667
0.75
0.8

Floor

Summary Rounds input down to the nearest whole number
Returns Floor of input
Remarks
Parameters
input input

Example

Context

{
    "a": 1.23,
    "b": 2.45,
    "c": 3.67
}

Usage

<strong>result:</strong>
{{Math.Floor a}}
{{Math.Floor b}}
{{Math.Floor c}}
{{Math.Floor 4.89}}

Returns

<strong>result:</strong>
1
2
3
4

Mod

Summary Modulus of first over second input
Returns Result of modulus of first input over second input
Remarks
Parameters
input1 First input
input2 Second input

Example

Context

{
    "a": 1,
    "b": 2,
    "c": 3
}

Usage

<strong>result:</strong>
{{Math.Mod a b}}
{{Math.Mod b c}}
{{Math.Mod c 4}}
{{Math.Mod 4 5}}

Returns

<strong>result:</strong>
1
2
3
4

Multiply

Summary Multiply first input by second input
Returns Result of multiplication of first input and second input
Remarks
Parameters
input1 First input
input2 Second input

Example

Context

{
    "a": 1,
    "b": 2,
    "c": 3
}

Usage

<strong>result:</strong>
{{Math.Multiply a b}}
{{Math.Multiply b c}}
{{Math.Multiply c 4}}
{{Math.Multiply 4 5}}

Returns

<strong>result:</strong>
2
6
12
20

Round

Summary Rounds input to the nearest whole number
Returns Rounded input
Remarks Rounds depending on what side of the half the number falls on
Parameters
input input

Example

Context

{
    "a": 1.23,
    "b": 2.45,
    "c": 3.67
}

Usage

<strong>result:</strong>
{{Math.Round a}}
{{Math.Round b}}
{{Math.Round c}}
{{Math.Round 4.89}}

Returns

<strong>result:</strong>
1
2
4
5

Subtract

Summary Subtract second input from first
Returns Result of subtracting the second input from first
Remarks
Parameters
input1 First input
input2 Second input

Example

Context

{
    "a": 4,
    "b": 3,
    "c": 1
}

Usage

<strong>result:</strong>
{{Math.Subtract a b}}
{{Math.Subtract b c}}
{{Math.Subtract c 2}}
{{Math.Subtract 2 5}}

Returns

<strong>result:</strong>
1
2
-1
-3
Clone this wiki locally