Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

divided_by filter incorrectly rounds down when divisor is float #88

Closed
kennytm opened this issue Apr 29, 2017 · 2 comments
Closed

divided_by filter incorrectly rounds down when divisor is float #88

kennytm opened this issue Apr 29, 2017 · 2 comments
Assignees
Milestone

Comments

@kennytm
Copy link

kennytm commented Apr 29, 2017

According to documentation, divided_by floors only when the divisor is an integer. Otherwise it should not round.

{{ 20 | divided_by: 7 }}
⇒ 2

{{ 20 | divided_by: 7.0 }}
⇒ 2.857142857142857

{% assign my_integer = 7 %}
{{ 20 | divided_by: my_integer }}
⇒ 2

{% assign my_integer = 7 %}
{% assign my_float = my_integer | times: 1.0 %}
{{ 20 | divided_by: my_float }}
⇒ 2.857142857142857

However, as of 0.9.1, all of these produce 2 as result since it floors unconditionally.

I think you may need to split Value::Num into two distinct variants to properly fix it.

@epage
Copy link
Member

epage commented Apr 30, 2017

Thanks for catching this.

Yeah, this will probably require integer support and we should probably audit the rest of the filters for when we should be returning integer or decimal values.

@epage epage added the bug Not as expected label May 5, 2017
epage added a commit to epage/liquid-rust that referenced this issue May 8, 2017
@epage epage added std-compatibility Jekyll flavor of liquid and removed bug Not as expected labels May 20, 2017
@epage epage added this to the 0.14 milestone Jan 7, 2018
@epage epage self-assigned this Jan 7, 2018
@epage
Copy link
Member

epage commented Jan 15, 2018

Fixed by #158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants