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

wrong rounding. #10

Merged
merged 5 commits into from
Apr 28, 2016
Merged

wrong rounding. #10

merged 5 commits into from
Apr 28, 2016

Conversation

Scrum
Copy link
Contributor

@Scrum Scrum commented Apr 23, 2016

I added example showing wrong rounding.

@MoOx
Copy link
Owner

MoOx commented Apr 23, 2016

Well, it's a JavaScript problem? Not sure how to fix that.

@Scrum
Copy link
Contributor Author

Scrum commented Apr 24, 2016

This not js problem.
This package will produce rounding in the intermediate calculations, instead of rounding the result.
Need to round off the final result of the computation.

Example:

*step: 1
(100/12) = 8.333333333333334 (pkg return 8.333)
(100*2) = 200

*step: 2
8.333*2 = 16.666
200/12 = 16.666666666666668

*step: 3 (round, 3)
result: Math.round(16.666 * 1000) / 1000 => 16.666
result: Math.round(16.666666666666668 * 1000) / 1000 => 16.667

@MoOx
Copy link
Owner

MoOx commented Apr 24, 2016

The problem is own this function works: it will reduce when possible, so for now it producing rounding for each calculations. If you have a better algorithm to fix this, PR is welcome :)

@Scrum
Copy link
Contributor Author

Scrum commented Apr 26, 2016

@MoOx Fixed

@Scrum
Copy link
Contributor Author

Scrum commented Apr 27, 2016

Ping!

@MoOx MoOx merged commit d9ba241 into MoOx:master Apr 28, 2016
@MoOx
Copy link
Owner

MoOx commented Apr 28, 2016

Released as 1.2.3

@Scrum
Copy link
Contributor Author

Scrum commented Apr 28, 2016

Thanks.

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

Successfully merging this pull request may close these issues.

2 participants