Math filters


Math filters perform math operations on numbers. You can use them on numbers, variables, or metafields that return a number.

Like other filters, you can use multiple math filters on one input. They apply from left to right. In the example below, minus is used first, then times, and finally divided_by.


abs

Syntax
number | abs

Returns the absolute value of a number.


at_least

Syntax
number | at_least

Limits a number to a minimum value.


at_most

Syntax
number | at_most

Limits a number to a maximum value.


ceil

Syntax
number | ceil

Rounds a number up to the nearest integer.


divided_by

Syntax
number | divided_by: number

Divides a number by another number. The divided_by filter generates a result of the same type as the divisor. This means if you divide by an integer, the result will be an integer, and if you divide by a float, the result will be a float.


floor

Syntax
number | floor

To round a number down to the nearest whole number.


minus

Syntax
number | minus: number

Subtracts one number from another number.


modulo

Syntax
number | modulo: number

Returns the leftover after dividing one number by another number.


plus

Syntax
number | plus: number

Adds two numbers.


round

Syntax
number | round

Rounds a number to the nearest integer.

Round to a specific number of decimal places

You can define how many decimal places to round to. If you don't specify a number, the round filter will round to the nearest whole number.


times

Syntax
number | times: number

Multiplies a number by a given number.