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

Bug Report: round2 is unreliable #1494

Closed
nikostr opened this issue Apr 17, 2023 · 1 comment · Fixed by #1496
Closed

Bug Report: round2 is unreliable #1494

nikostr opened this issue Apr 17, 2023 · 1 comment · Fixed by #1496
Milestone

Comments

@nikostr
Copy link

nikostr commented Apr 17, 2023

round2 does not reliably solve the issue of round not behaving in the expected way.

round2(2.5)
#> 2

It seems to be an issue with (number + .Machine$double.eps) == number being true for numbers greater than 2. Perhaps it would make sense to implement round2 as in this link? https://stackoverflow.com/questions/12688717/round-up-from-5/12688836#12688836 This is what janitor references in its implementation of round_half_up: https://github.com/sfirke/janitor/blob/main/R/round_half_up.R

@ddsjoberg ddsjoberg added this to the v1.7.1 milestone Apr 17, 2023
@ddsjoberg
Copy link
Owner

Thank you for reporting! Gah, I hate that simple rounding is made difficult in R!

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 a pull request may close this issue.

2 participants