> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kiwify.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Math filters

> Math filters for performing arithmetic operations in Liquid templates.

## `plus`

Adds a number to another number.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 4 | plus: 2 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    6
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 16 | plus: 4 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    20
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 183.357 | plus: 12 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    195.357
    ```
  </CodeGroup>
</Columns>

## `minus`

Subtracts a number from another number.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 4 | minus: 2 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    2
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 16 | minus: 4 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    12
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 183.357 | minus: 12 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    171.357
    ```
  </CodeGroup>
</Columns>

## `times`

Multiplies a number by another number.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 3 | times: 2 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    6
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 24 | times: 7 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    168
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 183.357 | times: 12 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    2200.284
    ```
  </CodeGroup>
</Columns>

## `divided_by`

Divides a number by another number. The result is the string obtained by JavaScript `.toString()` of the result number.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 16 | divided_by: 4 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    4
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 5 | divided_by: 3 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    1.6666666666666667
    ```
  </CodeGroup>
</Columns>

In JavaScript, float and integer shares the same type `number` and we cannot tell the difference. For example:

```javascript theme={null}
// always true
5.0 === 5
```

You'll need to pass another `integerArithmetic` argument to enforce integer divide:

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 5 | divided_by: 3, true }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    1
    ```
  </CodeGroup>
</Columns>

## `modulo`

Returns the remainder of a division operation.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 3 | modulo: 2 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    1
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 24 | modulo: 7 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    3
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 183.357 | modulo: 12 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    3.3569999999999993
    ```
  </CodeGroup>
</Columns>

## `abs`

Liquid filter that returns the absolute value of a number.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ -17 | abs }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    17
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 4 | abs }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    4
    ```
  </CodeGroup>
</Columns>

`abs` will also work on a string that only contains a number:

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ "-19.86" | abs }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    19.86
    ```
  </CodeGroup>
</Columns>

## `at_least`

Limits a number to a minimum value.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 4 | at_least: 5 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    5
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 4 | at_least: 3 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    4
    ```
  </CodeGroup>
</Columns>

## `at_most`

Limits a number to a maximum value.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 4 | at_most: 5 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    4
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 4 | at_most: 3 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    3
    ```
  </CodeGroup>
</Columns>

## `ceil`

Rounds the input up to the nearest whole number. LiquidJS tries to convert the input to a number before the filter is applied.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 1.2 | ceil }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    2
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 2.0 | ceil }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    2
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 183.357 | ceil }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    184
    ```
  </CodeGroup>
</Columns>

Here the input value is a string:

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ "3.5" | ceil }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    4
    ```
  </CodeGroup>
</Columns>

## `floor`

Rounds the input down to the nearest whole number. LiquidJS tries to convert the input to a number before the filter is applied.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 1.2 | floor }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    1
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 2.0 | floor }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    2
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 183.357 | floor }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    183
    ```
  </CodeGroup>
</Columns>

Here the input value is a string:

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ "3.5" | floor }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    3
    ```
  </CodeGroup>
</Columns>

## `round`

Rounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal places.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 1.2 | round }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    1
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 2.7 | round }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    3
    ```
  </CodeGroup>
</Columns>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {{ 183.357 | round: 2 }}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    183.36
    ```
  </CodeGroup>
</Columns>

## `sum`

Computes the sum of all the numbers in an array.
An optional argument specifies which property of the array's items to sum up.

In this example, assume the object `cart.products` contains an array of all products in the cart of a website.
Assume each cart product has a `qty` property that gives the count of that product instance in the cart.
Using the `sum` filter we can calculate the total number of products in the cart.

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    The cart has {{ order.products | sum: "qty" }} products.
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    The cart has 7 products.
    ```
  </CodeGroup>
</Columns>
