Liquid Filter Reference for divided_by - v0.9.5

Filter Name divided_by
Group Numbers
Version 0.9.5

Description

Divides a number by another number.

Examples

The result is rounded down to the nearest integer if the divisor is an integer:
{{ 16 | divided_by: 4 }}
4
{{ 5 | divided_by: 3 }}
1
When the divisor is an integer, it returns the result as an integer:
{{ 20 | divided_by: 7 }}
2
When the divisor is a float, it returns the result as a float:
{{ 20 | divided_by: 7.0 }}
2.857142857142857
You can multiply an integer variable by 1.0 to get a float, then divide by the float instead:
{% assign an_integer = 7 %}
{% assign a_float = an_integer | times: 1.0 %}
{{ 20 | divided_by: a_float }}
2.857142857142857

Back to Filter List

Back to Liquid Reference for 0.9.5

 

 
Back to Documentation