Numeric
The Numeric registry includes a range of utilities for performing numerical operations and calculations, making it easier to handle numbers and perform math functions in your templates.
You can easily import all the functions from the numeric
registry by including the following import statement in your code
floor
The function returns the largest integer that is less than or equal to the provided number.
Signature
ceil
The function returns the smallest integer that is greater than or equal to the provided number.
Signature
round
The function rounds a number to a specified precision, allowing control over the number of decimal places. It also considers an optional rounding threshold to determine whether to round up or down (default to 0.5).
Signature
add / addf
The function performs addition on a slice of values, summing all elements in the slice and returning the total.
Signature
add1 / add1f
The function performs a unary addition, incrementing the provided value by one.
Signature
sub / subf
The function performs subtraction on a slice of values, starting with the first value and subtracting each subsequent value from it.
Signature
mul
The function multiplies a sequence of values together and returns the result as an int64
.
Signature
mulf
The function multiplies a sequence of values and returns the result as a float64
.
Signature
div
The function divides a sequence of values and returns the result as an int64
.
Signature
divf
The function divides a sequence of values, starting with the first value, and returns the result as a float64
.
Signature
mod
The function returns the remainder of the division of x
by y
.
Signature
min
The function returns the minimum value among the provided arguments.
Signature
minf
The function returns the minimum value among the provided floating-point arguments.
Signature
max
The function returns the maximum value among the provided arguments.
Signature
maxf
The function returns the maximum value among the provided floating-point arguments.
Signature
Last updated