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

Round.java default is HALF_EVEN #106

Closed
skfs opened this issue Nov 13, 2018 · 3 comments
Closed

Round.java default is HALF_EVEN #106

skfs opened this issue Nov 13, 2018 · 3 comments

Comments

@skfs
Copy link

skfs commented Nov 13, 2018

Hi.
The "round" filter (Round.java) uses the default rounding in DecimalFormat.class which is HALF_EVEN.
I believe that HALF_UP may be the correct, but I have no data/reference to back this up.
HALF_UP rounds all numbers up when the decimal is higher or equal to .5, whereas HALF_EVEN rounds to the nearest neighbour (as do HALF_UP), but when equal distance to the neighbour, it rounds to the value that is even. So 10.5 becomes 10, and 11.5 becomes 12.
At least in Denmark the default rounding is always to round upwards when reached .5 in decimal.

@skfs
Copy link
Author

skfs commented Nov 13, 2018

Actually I just created a temporary Shopify shop and made a template that uses {{ 10.5 | round }} .
The final result is: 11, so Shopify rounds HALF_UP.

@mbaumbach
Copy link
Contributor

mbaumbach commented Nov 13, 2018

@skfs @bkiers I submitted a pull request (#108) that switches this to HALF_UP RoundingMode.

@bkiers
Copy link
Owner

bkiers commented Nov 13, 2018

Thanks for raising the issue @skfs and @mbaumbach for the quick fix!

@bkiers bkiers closed this as completed Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants