All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
{% 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 👍