Rounding of results

140 views
Skip to first unread message

Masteroll

unread,
Oct 13, 2011, 12:12:01 PM10/13/11
to liquid-t...@googlegroups.com
Good day!
Please help me:
I have a construction like this:

{% if product.price 1000 %} Only  {{ product.sale_prictimes:1.3divided_by12}} per month!{%endif%}

But some results that I recieveing is like: 2,6999999998.
I asked my developer about this, and he told that theres no in Liquid such function
Is it true?

Jonathan Rudenberg

unread,
Oct 16, 2011, 11:06:17 AM10/16/11
to liquid-t...@googlegroups.com
Hi Masteroll,

What you're getting is a float, which isn't exact:
http://en.wikipedia.org/wiki/IEEE_754-2008

Depending on the type of rounding you need, there is a truncate filter
that might work, or you/your developer can write a new filter.

https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers

Jonathan

--
Jonathan Rudenberg
Developer
http://shopify.com - e-commerce done right

> --
> You received this message because you are subscribed to the Google Groups
> "Liquid Templates" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/liquid-templates/-/xDGLdaSH7FUJ.
> To post to this group, send email to liquid-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> liquid-templat...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/liquid-templates?hl=en.
>

Reply all
Reply to author
Forward
0 new messages