I’m trying to calculate growth rate between two months and I’m getting round numbers instead of floating. Is there a way to prevent liquid from rounding numbers?
{{ articles_created_this_month_count | minus: articles_created_last_month_count | divided_by: articles_created_last_month_count | times: 100 }}%
{{ articles_created_this_month_count | minus: articles_created_last_month_count | divided_by: articles_created_last_month_count | times: 100 }}%
2
Answers
use javascript for pet projects like this where Liquid is not appropriate
As with many programming languages, when Liquid divides an integer with an integer, the result will always be an integer again. So
5 / 2
will equal2
. But5.0 / 2
will be2.5
. So you could multiple yourarticles_created_this_month_count
with1.0
: