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  number

Returns the absolute value of a number.

{{ -10 | abs }}
10

ceil

number | ceil
returns  number

Rounds a number up to the nearest integer.

{{ 12.2 | ceil }}
13

divided_by

number | divided_by: number
returns  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.75

floor

number | floor
returns  number

Rounds a number down to the nearest integer.

{{ 12.88 | floor }}
12

minus

number | minus: number
returns  number

Subtracts a given number from another number.

{{ 12 | minus: 3 }}
9

modulo

number | modulo: number
returns  number

Returns the remainder of dividing a number by a given number.

{{ 12 | modulo: 5 }}
2

plus

number | plus: number
returns  number

Adds two numbers.

{{ 9 | plus: 3 }}
12

round

number | round
returns  number

Rounds a number to the nearest integer.

{{ 3.9 | round }}

{{ 1.2 | round }}
4

1

Round to a specific number of decimal places

number | round: number
returns  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.14

times

number | times: number
returns  number

Multiplies a number by a given number.

{{ 2 | times: 3 }}
6