Arithmetic Helpers
Arithmetic helpers provide basic mathematical operations for integer values.
| Helper | Purpose | Parameters | Returns |
|---|---|---|---|
inc | Increments a numeric value by one | value | number |
dec | Decrements a numeric value by one | value | number |
add | Adds two numeric values | value1, value2 | number |
sub | Subtracts a numeric value from another | value1, value2 | number |
mul | Multiplies two numeric values | value1, value2 | number |
div | Divides one numeric value by another | value1, value2 | number |
mod | Modulus of two numeric values | value1, value2 | number |
abs | Absolute value of a numeric value | value | number |
inc
Increments a numeric value by one.
Syntax:
{{#inc value}}
Parameters:
value(number) - The value to increment
Returns: The incremented value as an integer.
Examples:
{{#inc 5}} {{!-- 6 --}}
{{#inc @index}} {{!-- Current index + 1 --}}
dec
Decrements a numeric value by one.
Syntax:
{{#dec value}}
Parameters:
value(number) - The value to decrement
Returns: The decremented value as an integer.
Examples:
{{#dec 5}} {{!-- 4 --}}
{{#dec @index}} {{!-- Current index - 1 --}}
add
Adds two numeric values together.
Syntax:
{{#add value1 value2}}
Parameters:
value1(number) - The first value to addvalue2(number) - The second value to add
Returns: The sum of the two values as an integer.
Examples:
{{#add 5 10}} {{!-- 15 --}}
{{#add @index 2}} {{!-- Current index + 2 --}}
sub
Subtracts the second numeric value from the first.
Syntax:
{{#sub value1 value2}}
Parameters:
value1(number) - The first valuevalue2(number) - The second value
Returns: The difference between the two values as an integer.
Examples:
{{#sub 10 5}} {{!-- 5 --}}
{{#sub @index 1}} {{!-- Current index - 1 --}}
mul
Multiplies two numeric values together.
Syntax:
{{#mul value1 value2}}
Parameters:
value1(number) - The first value to multiplyvalue2(number) - The second value to multiply
Returns: The product of the two values as an integer.
Examples:
{{#mul 5 10}} {{!-- 50 --}}
{{#mul @index 2}} {{!-- Current index * 2 --}}
div
Divides the first numeric value by the second.
Syntax:
{{#div value1 value2}}
Parameters:
value1(number) - The numeratorvalue2(number) - The denominator
Returns: The result of the division as an integer.
Examples:
{{#div 10 5}} {{!-- 2 --}}
{{#div @index 2}} {{!-- Current index / 2 --}}
mod
Calculates the modulus of the first numeric value by the second.
Syntax:
{{#mod value1 value2}}
Parameters:
value1(number) - The dividendvalue2(number) - The divisor
Returns: The remainder of the division as an integer.
Examples:
{{#mod 10 3}} {{!-- 1 --}}
{{#mod @index 2}} {{!-- Current index % 2 --}}
abs
Calculates the absolute value of a numeric value.
Syntax:
{{#abs value}}
Parameters:
value(number) - The value to calculate the absolute value of
Returns: The absolute value of the input as an integer.
Examples:
{{#abs -5}} {{!-- 5 --}}
{{#abs 10}} {{!-- 10 --}}
