What is the quick way to get only the decimal place from a float, preferably by a filter? For example: 1.45 → 0.45.
Thanks.
What is the quick way to get only the decimal place from a float, preferably by a filter? For example: 1.45 → 0.45.
Thanks.
The quickest way is like this:
{{ 1.45 % 1 }}
However, you are not going to live the result because it encounters what is known as machine epsilon error. Paste it into the Template Editor to see what I mean.
Thanks a lot. I can live with that by a reformat
{{'%0.2f'| format(1.45 % 1)}}
or
{{ (1.45 % 1) | round(2) }}