All things Shopify and commerce
{% assign max_avail_columns = 3 | divided_by: 5 | ceil %} code return 0 value with ceil formatter, it should return 1. I think this is a bug in Liquid. It should (3/5=0.6) and ceil(0.6)=1 but return 0
Solved! Go to the solution
This is an accepted solution.
It’s not a bug — it’s just how Liquid handles numbers. When you write 3 | divided_by: 5, Liquid does integer math, so the result is 0. Then 0 | ceil is still 0.
To fix it, make one of the numbers a decimal:
{% assign max_avail_columns = 3.0 | divided_by: 5 | ceil %}
Now it does 3.0 ÷ 5 = 0.6, and ceil turns that into 1.
This is an accepted solution.
It’s not a bug — it’s just how Liquid handles numbers. When you write 3 | divided_by: 5, Liquid does integer math, so the result is 0. Then 0 | ceil is still 0.
To fix it, make one of the numbers a decimal:
{% assign max_avail_columns = 3.0 | divided_by: 5 | ceil %}
Now it does 3.0 ÷ 5 = 0.6, and ceil turns that into 1.
Thank you, DrewOswald i found the solution based on your reply, that is {% assign max_avail_columns = 3.0 | plus:0.0 | divided_by: 5 | ceil %} its gives the correct value 👍
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025