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_half_up() fails to round up for certain decimals (precision issue) #396

Closed
sfirke opened this issue Aug 4, 2020 · 0 comments
Closed

Comments

@sfirke
Copy link
Owner

sfirke commented Aug 4, 2020

From the StackOverflow post where I found this function, someone pointed out a bug in June:

There are numerical precision issues, e.g., round2(2436.845, 2) returns 2436.84. Changing z + 0.5 to z + 0.5 + sqrt(.Machine$double.eps) seems to work for me

Indeed, round_half_up(2436.845, 2) yields 2436.84. This function should probably have the same fix implemented, along with a test.

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

1 participant