-
-
Notifications
You must be signed in to change notification settings - Fork 21
Math
Stef Heyenrath edited this page Apr 18, 2020
·
5 revisions
These helpers provide the ability to perform some calculations within a template.
- Add / Plus
- Abs
- Avg
- Ceiling
- Divide
- Floor
- Max
- Min
- Modulo
- Multiply / Times
- Power
- Round
- Sign
- Subtract / Minus
- Sqrt
Summary | Add two numbers |
Returns | Sum of inputs |
Remarks | |
Parameters | |
input1 | First input |
input2 | Second input |
Context
{
"a": 1,
"b": 2,
"c": 3
}
Usage
<strong>result:</strong>
{{Add a b}}
{{Add b c}}
{{Add c 4}}
{{Add 4 5}}
Returns
<strong>result:</strong>
3
5
7
9
Summary | Rounds input up to the nearest whole number |
Returns | Ceiling of input |
Remarks | |
Parameters | |
input | input |
Context
{
"a": 1.23,
"b": 2.45,
"c": 3.67
}
Usage
<strong>result:</strong>
{{Ceiling a}}
{{Ceiling b}}
{{Ceiling c}}
{{Ceiling 4.89}}
Returns
<strong>result:</strong>
2
3
4
5
Summary | Divide first input by second input |
Returns | Result of first input divided by second input |
Remarks | |
Parameters | |
input1 | First input |
input2 | Second input |
Context
{
"a": 1,
"b": 2,
"c": 3
}
Usage
<strong>result:</strong>
{{Divide a b}}
{{Divide b c}}
{{Divide c 4}}
{{Divide 4 5}}
Returns
<strong>result:</strong>
0.5
0.666666666666667
0.75
0.8
Summary | Rounds input down to the nearest whole number |
Returns | Floor of input |
Remarks | |
Parameters | |
input | input |
Context
{
"a": 1.23,
"b": 2.45,
"c": 3.67
}
Usage
<strong>result:</strong>
{{Floor a}}
{{Floor b}}
{{Floor c}}
{{Floor 4.89}}
Returns
<strong>result:</strong>
1
2
3
4
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 |
Context
{
"a": 1,
"b": 2,
"c": 3
}
Usage
<strong>result:</strong>
{{Mod a b}}
{{Mod b c}}
{{Mod c 4}}
{{Mod 4 5}}
Returns
<strong>result:</strong>
1
2
3
4
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 |
Context
{
"a": 1,
"b": 2,
"c": 3
}
Usage
<strong>result:</strong>
{{Multiply a b}}
{{Multiply b c}}
{{Multiply c 4}}
{{Multiply 4 5}}
Returns
<strong>result:</strong>
2
6
12
20
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 |
Context
{
"a": 1.23,
"b": 2.45,
"c": 3.67
}
Usage
<strong>result:</strong>
{{Round a}}
{{Round b}}
{{Round c}}
{{Round 4.89}}
Returns
<strong>result:</strong>
1
2
4
5
Summary | Subtract second input from first |
Returns | Result of subtracting the second input from first |
Remarks | |
Parameters | |
input1 | First input |
input2 | Second input |
Context
{
"a": 4,
"b": 3,
"c": 1
}
Usage
<strong>result:</strong>
{{Subtract a b}}
{{Subtract b c}}
{{Subtract c 2}}
{{Subtract 2 5}}
Returns
<strong>result:</strong>
1
2
-1
-3