Math
Math filters perform mathematical operations on numbers. You can apply math filters to numbers, variables, or metafields that return a number.
As with any other filters, you can use multiple math filters on a single input. They’re applied from left to right. In the example below, minus is applied first, then times, and finally divided_by.
You save {{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price }}%abs
number |
abs
Returns the absolute value of a number.
{{ -10 | abs }}10ceil
number |
ceil
Rounds a number up to the nearest integer.
{{ 12.2 | ceil }}13divided_by
number |
divided_by:
number
Divides a number by a given number.
{{ 4 | divided_by: 2 }}
{{ 15 | divided_by: 4 }}
{{ 15 | divided_by: 4.0 }}2
3.75
3.75floor
number |
floor
Rounds a number down to the nearest integer.
{{ 12.88 | floor }}12minus
number |
minus:
number
Subtracts a given number from another number.
{{ 12 | minus: 3 }}9modulo
number |
modulo:
number
Returns the remainder of dividing a number by a given number.
{{ 12 | modulo: 5 }}2plus
number |
plus:
number
Adds two numbers.
{{ 9 | plus: 3 }}12round
number |
round
Rounds a number to the nearest integer.
{{ 3.9 | round }}
{{ 1.2 | round }}4
1Round to a specific number of decimal places
number |
round:
number
You can specify a number of decimal places to round to. If you don't specify a number, then the round filter rounds to the nearest integer.
{{ 3.14159 | round: 2 }}3.14times
number |
times:
number
Multiplies a number by a given number.
{{ 2 | times: 3 }}6Updated 7 days ago
